Std.Dynamic.Number
Number
Section titled “Number”opaque type NumberA decimal number of any size and precision: a sign, digits and an exponent. Two numbers that
denote the same value are equal (1.0 and 1e0).
OutOfRange
Section titled “OutOfRange”error OutOfRange(number: Number)A number that the target type cannot hold.
number: Number
fn parse(s: String) -> Number fails ParseErrorReads a number in the JSON grammar: an optional -, an integer part without leading zeros,
an optional . and fraction, and an optional e or E with an optional sign and digits.
Fails also when the normalized exponent is outside the range of Int.
from_int
Section titled “from_int”fn from_int(n: Int) -> NumberThe number n, exactly.
from_int64
Section titled “from_int64”fn from_int64(n: Int64) -> NumberThe number n, exactly.
from_float
Section titled “from_float”fn from_float(f: Float) -> Option[Number]None for NaN and the infinities, which no number can hold.
to_int
Section titled “to_int”fn to_int(n: Number) -> Int fails OutOfRangen as an Int. Fails if n is not an integer or is outside the range of Int.
to_int64
Section titled “to_int64”fn to_int64(n: Number) -> Int64 fails OutOfRangen as an Int64. Fails if n is not an integer or is outside the range of Int64.
to_float
Section titled “to_float”fn to_float(n: Number) -> FloatThe Float nearest to n.
to_string
Section titled “to_string”fn to_string(n: Number) -> StringIntegral values up to 21 digits are written in full (1500), values with a short enough
fraction with a point (0.25), and the rest with an exponent (1.5e300).