pub type Number = Rational;Expand description
The underlying type representing Nickel numbers. Currently, numbers are arbitrary precision rationals.
Basic arithmetic operations are exact, without loss of precision (within the limits of available memory).
Raising to a power that doesn’t fit in a signed 64bits number will lead to converting both operands to 64-bits floats, performing the floating-point power operation, and converting back to rationals, which can incur a loss of precision.
Conversion to string and serialization try to first convert the rational as an exact signed or usigned 64-bits integer. If this succeeds, such operations don’t lose precision. Otherwise, the number is converted to the nearest 64bit float and then serialized/printed, which can incur a loss of information. ↩
Aliased Type§
pub struct Number { /* private fields */ }