numbers

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package numbers implement elements representing numbers for the interpreter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Float

type Float struct {
	// contains filtered or unexported fields
}

Float is a GX number.

func NewFloat

func NewFloat(expr elements.ExprAt, val *big.Float) *Float

NewFloat returns a new element Float number element.

func (*Float) BinaryOp

BinaryOp applies a binary operator to x and y. Note that the receiver can be either the left or right argument.

func (*Float) CanonicalExpr

func (n *Float) CanonicalExpr() canonical.Canonical

CanonicalExpr returns the canonical expression used for comparison.

func (*Float) Cast

func (n *Float) Cast(ctx ir.Evaluator, expr ir.AssignableExpr, target ir.Type) (evaluator.NumericalElement, error)

Cast an element into a given data type.

func (*Float) Compare

func (n *Float) Compare(x canonical.Comparable) bool

Compare with another number.

func (*Float) Float

func (n *Float) Float() *big.Float

Float value of the number.

func (*Float) Reshape

func (n *Float) Reshape(ctx ir.Evaluator, expr ir.AssignableExpr, axisLengths []evaluator.NumericalElement) (evaluator.NumericalElement, error)

Reshape the number into an array.

func (*Float) Shape

func (n *Float) Shape() *shape.Shape

Shape of the value represented by the element.

func (*Float) Simplify

func (n *Float) Simplify() canonical.Simplifier

Simplify returns the expression simplified.

func (*Float) String

func (n *Float) String() string

String return the float literal.

func (*Float) Type added in v0.3.0

func (n *Float) Type() ir.Type

Type of the element.

func (*Float) UnaryOp

func (n *Float) UnaryOp(ctx ir.Evaluator, expr *ir.UnaryExpr) (evaluator.NumericalElement, error)

UnaryOp applies a unary operator on x.

type Int

type Int struct {
	// contains filtered or unexported fields
}

Int is a GX number.

func (*Int) BinaryOp

BinaryOp applies a binary operator to x and y. Note that the receiver can be either the left or right argument.

func (*Int) CanonicalExpr

func (n *Int) CanonicalExpr() canonical.Canonical

CanonicalExpr returns the canonical expression used for comparison.

func (*Int) Cast

func (n *Int) Cast(ctx ir.Evaluator, expr ir.AssignableExpr, target ir.Type) (evaluator.NumericalElement, error)

Cast an element into a given data type.

func (*Int) Compare

func (n *Int) Compare(x canonical.Comparable) bool

Compare with another number.

func (*Int) Float

func (n *Int) Float() *big.Float

Float value of the integer.

func (*Int) Reshape

func (n *Int) Reshape(ctx ir.Evaluator, expr ir.AssignableExpr, axisLengths []evaluator.NumericalElement) (evaluator.NumericalElement, error)

Reshape the number into an array.

func (*Int) Shape

func (n *Int) Shape() *shape.Shape

Shape of the value represented by the element.

func (*Int) String

func (n *Int) String() string

String return the float literal.

func (*Int) Type added in v0.3.0

func (n *Int) Type() ir.Type

Type of the element.

func (*Int) UnaryOp

func (n *Int) UnaryOp(ctx ir.Evaluator, expr *ir.UnaryExpr) (evaluator.NumericalElement, error)

UnaryOp applies a unary operator on x.

type Number

Number value in GX.

func NewInt

func NewInt(expr elements.ExprAt, val *big.Int) Number

NewInt returns a new element Int number element.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL