Skip to main content

Module numeric_cmp

Module numeric_cmp 

Source
Expand description

Numeric readings and their total order, shared by every comparison path.

  • An integer reads as an exact i128. i128 holds every i64 and every u64.
  • A fractional Decimal reads as an exact Decimal. A DECIMAL cell is stored as its text, so numeric text with a fraction reads as a Decimal too.
  • A float reads as an f64.
  • Integer and decimal pairs compare exactly. An integer against a float compares exactly. A decimal against a float compares as f64.
  • NaN sorts above every number and equals NaN, as in PostgreSQL. The order is total, so a sort over it never panics.

Enums§

Numeric
The numeric reading of a value for comparison and summation.

Functions§

cmp_f64
Total order of two floats. NaN sorts above every number and equals NaN. -0.0 equals 0.0.
cmp_numeric
Total order of two numeric readings. See the module docs for the rule.
decimal_reading
An integral Decimal as an exact integer, any other as an exact Decimal.
numeric_bucket_bits
The f64 a numeric reading rounds to, by the same conversion cmp_numeric uses for a decimal against a float. Two readings cmp_numeric orders Equal round to the same f64, with -0.0 read as 0.0 and every NaN as one NaN. Distinct readings can share an f64, so this is a hash bucket, never an equality.
numeric_eq
Equality of two numeric readings for a coerced =: cmp_numeric orders the pair Equal. Exact for every pair, as PostgreSQL float = is, and NaN equals NaN.
parse_numeric_str
A numeric string read as a number: integer text as an exact integer, fractional decimal text as an exact Decimal, and any other float text (an exponent, a fraction past the Decimal precision, NaN, inf) as an f64. None for non-numeric text.