Documentation ¶
Index ¶
- type FloatNumber
- func (f *FloatNumber) Abs() *FloatNumber
- func (f *FloatNumber) Add(x any) *FloatNumber
- func (f *FloatNumber) BigFloat() *big.Float
- func (f *FloatNumber) BigInt() *big.Int
- func (f *FloatNumber) Cmp(x any) int
- func (f *FloatNumber) Div(x any) *FloatNumber
- func (f *FloatNumber) Float64() float64
- func (f *FloatNumber) Int() *IntNumber
- func (f *FloatNumber) Inv() *FloatNumber
- func (f *FloatNumber) IsInf() bool
- func (f *FloatNumber) Mul(x any) *FloatNumber
- func (f *FloatNumber) Neg() *FloatNumber
- func (f *FloatNumber) Sign() int
- func (f *FloatNumber) Sqrt() *FloatNumber
- func (f *FloatNumber) String() string
- func (f *FloatNumber) Sub(x any) *FloatNumber
- func (f *FloatNumber) Text(format byte, prec int) string
- type IntNumber
- func (i *IntNumber) Abs() *IntNumber
- func (i *IntNumber) Add(x any) *IntNumber
- func (i *IntNumber) BigFloat() *big.Float
- func (i *IntNumber) BigInt() *big.Int
- func (i *IntNumber) Cmp(x any) int
- func (i *IntNumber) Div(x any) *IntNumber
- func (i *IntNumber) DivRoundUp(x any) *IntNumber
- func (i *IntNumber) Float() *FloatNumber
- func (i *IntNumber) Int64() int64
- func (i *IntNumber) Lsh(n uint) *IntNumber
- func (i *IntNumber) Mul(x any) *IntNumber
- func (i *IntNumber) Neg() *IntNumber
- func (i *IntNumber) Pow(x any) *IntNumber
- func (i *IntNumber) Rem(x any) *IntNumber
- func (i *IntNumber) Rsh(n uint) *IntNumber
- func (i *IntNumber) Sign() int
- func (i *IntNumber) Sqrt() *IntNumber
- func (i *IntNumber) String() string
- func (i *IntNumber) Sub(x any) *IntNumber
- func (i *IntNumber) Text(base int) string
- func (i *IntNumber) Uint64() uint64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FloatNumber ¶ added in v0.10.2
type FloatNumber struct {
// contains filtered or unexported fields
}
FloatNumber represents a floating-point number.
func Float ¶
func Float(x any) *FloatNumber
Float returns the FloatNumber representation of x.
The argument x can be one of the following types:
- IntNumber
- FloatNumber
- big.Int
- big.Float
- int, int8, int16, int32, int64
- uint, uint8, uint16, uint32, uint64
- float32, float64
- string - a string accepted by big.Float.SetString, otherwise it returns nil
If the input value is not one of the supported types, nil is returned.
func (*FloatNumber) Abs ¶ added in v0.10.2
func (f *FloatNumber) Abs() *FloatNumber
Abs returns the absolute value of the number.
func (*FloatNumber) Add ¶ added in v0.10.2
func (f *FloatNumber) Add(x any) *FloatNumber
Add adds x to the number and returns the result.
The x argument can be any of the types accepted by Float.
func (*FloatNumber) BigFloat ¶ added in v0.10.2
func (f *FloatNumber) BigFloat() *big.Float
BigFloat returns the *big.Float representation of the Float.
func (*FloatNumber) BigInt ¶ added in v0.10.2
func (f *FloatNumber) BigInt() *big.Int
BigInt returns the *big.Int representation of the Float. The fractional part is discarded.
func (*FloatNumber) Cmp ¶ added in v0.10.2
func (f *FloatNumber) Cmp(x any) int
Cmp compares the number with x and returns:
-1 if x < y 0 if x == y (incl. -0 == 0, -Inf == -Inf, and +Inf == +Inf) +1 if x > y
The x argument can be any of the types accepted by Float.
func (*FloatNumber) Div ¶ added in v0.10.2
func (f *FloatNumber) Div(x any) *FloatNumber
Div divides the number by x and returns the result.
The x argument can be any of the types accepted by Float.
func (*FloatNumber) Float64 ¶ added in v0.10.2
func (f *FloatNumber) Float64() float64
Float64 returns the float64 representation of the Float.
func (*FloatNumber) Int ¶ added in v0.10.2
func (f *FloatNumber) Int() *IntNumber
Int returns the IntNumber representation of the Float. The fractional part is discarded.
func (*FloatNumber) Inv ¶ added in v0.10.2
func (f *FloatNumber) Inv() *FloatNumber
Inv returns the inverse value of the number.
func (*FloatNumber) IsInf ¶ added in v0.10.2
func (f *FloatNumber) IsInf() bool
IsInf reports whether the number is an infinity.
func (*FloatNumber) Mul ¶ added in v0.10.2
func (f *FloatNumber) Mul(x any) *FloatNumber
Mul multiplies the number by x and returns the result.
The x argument can be any of the types accepted by Float.
func (*FloatNumber) Neg ¶ added in v0.10.2
func (f *FloatNumber) Neg() *FloatNumber
Neg returns the negative value of the number.
func (*FloatNumber) Sign ¶ added in v0.10.2
func (f *FloatNumber) Sign() int
Sign returns:
-1 if f < 0 0 if f == 0 +1 if f > 0
func (*FloatNumber) Sqrt ¶ added in v0.10.2
func (f *FloatNumber) Sqrt() *FloatNumber
Sqrt returns the square root of the number.
func (*FloatNumber) String ¶ added in v0.10.2
func (f *FloatNumber) String() string
String returns the 10-base string representation of the Float.
func (*FloatNumber) Sub ¶ added in v0.10.2
func (f *FloatNumber) Sub(x any) *FloatNumber
Sub subtracts x from the number and returns the result.
The x argument can be any of the types accepted by Float.
type IntNumber ¶ added in v0.10.2
type IntNumber struct {
// contains filtered or unexported fields
}
IntNumber represents an arbitrary-precision integer.
func Int ¶
Int returns the IntNumber representation of x.
The argument x can be one of the following types:
- IntNumber
- FloatNumber - the fractional part is discarded
- big.Int
- big.Float - the fractional part is discarded
- int, int8, int16, int32, int64
- uint, uint8, uint16, uint32, uint64
- float32, float64 - the fractional part is discarded
- string - a string accepted by big.Int.SetString, otherwise it returns nil
- []byte - big-endian representation of the integer
If the input value is not one of the supported types, nil is returned.
func (*IntNumber) Add ¶ added in v0.10.2
Add adds x to the number and returns the result.
The x argument can be any of the types accepted by Int.
func (*IntNumber) BigFloat ¶ added in v0.10.2
BigFloat returns the *big.Float representation of the Int.
func (*IntNumber) Cmp ¶ added in v0.10.2
Cmp compares the number to x and returns:
-1 if i < x 0 if i == x +1 if i > x
The x argument can be any of the types accepted by Int.
func (*IntNumber) Div ¶ added in v0.10.2
Div divides the number by x and returns the result.
The x argument can be any of the types accepted by Int.
func (*IntNumber) DivRoundUp ¶ added in v0.10.2
DivRoundUp divides the number by x and returns the result rounded up.
The x argument can be any of the types accepted by Int.
func (*IntNumber) Float ¶ added in v0.10.2
func (i *IntNumber) Float() *FloatNumber
Float returns the Float representation of the Int.
func (*IntNumber) Mul ¶ added in v0.10.2
Mul multiplies the number by x and returns the result.
The x argument can be any of the types accepted by Int.
func (*IntNumber) Pow ¶ added in v0.10.2
Pow returns the number raised to the power of x.
The x argument can be any of the types accepted by Int.
func (*IntNumber) Rem ¶ added in v0.10.2
Rem returns the remainder of the division of the number by x.
The x argument can be any of the types accepted by Int.
func (*IntNumber) String ¶ added in v0.10.2
String returns the 10-base string representation of the Int.
func (*IntNumber) Sub ¶ added in v0.10.2
Sub subtracts x from the number and returns the result.
The x argument can be any of the types accepted by Int.