Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Number ¶
type Number struct {
// contains filtered or unexported fields
}
Number is a versatile numeric representation that can hold different types of numeric values, such as integers, floating-point numbers, unsigned integers, as well as arbitrary-precision numbers (big integers and big floats).
The actual type of the numeric value stored is determined by the field 't' which is of type ValueType. Depending on this type: - For ValueType 'Int', the 'i' field (of type int) stores the value. - For ValueType 'Float', the 'f' field (of type float64) stores the value. - For ValueType 'Uint', the 'ui' field (of type uint64) stores the value. - For ValueType 'BigInt', the 'bi' field (a pointer to big.Int) stores the value. - For ValueType 'BigFloat', the 'bf' field (a pointer to big.Float) stores the value.
The appropriate field should be accessed based on the ValueType to get the correct numeric value. Methods like I(), F(), Ui(), Bi(), and Bf() are provided to retrieve these values safely.
It's also worth noting that the zero value of this struct isn't a valid representation and would need initialization before use. The FromString function can be used to initialize a Number from its string representation.
func FromString ¶
FromString creates a new Number from a string representation. It determines the appropriate type of the number based on the provided string and a flag indicating whether it's a big number.
func NewBigFloat ¶
NewBigFloat creates a new Number from a *big.Float value.