Decimal numbers, after Douglas Crockfords idea See http://dec64.com/
extract the coefficient from a Decimal
extract the exponent, sign extended in an Int
Interpret the bits of the Long value as a Decimal This is a no-operation, as Decimals are Longs and every Long value is a valid Decimal (though it might not be a number, see also Decimal.nan).
tell if a Decimal is not a number. This works for all 2^56 NaN values.
tell if a Decimal is 0. This works for all 255 0 values.
the largest possible coefficient is 36028797018963967
the largest exponent is 127
the smalles possible coefficient is -36028797018963968
the smallest exponent is -127
The canonical not a number value.
Note that there are 2^56 NaN values, all comparing equal.
The canonical Decimal 1
construct a Decimal from a coefficient and an exponent
This will be Decimal.nan if the coefficient is not in the range minCoefficient .. maxCoefficient or the exponent is not in the range minExponent .. maxExponent, even if the value could be represented. Thus:
Decimal.pack 36028797018963967 0 == 36028797018963967z Decimal.pack 360287970189639670 (-1) == nan
the sign of a Decimal (either -1, 0 or 1)
Interpret the bits of a Decimal as Long value. The result will look like this
mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm eeee eeee 54 48 40 32 24 16 8 7 0
Note that there are usually several encodings for one and the same value. 1, for example, could be 0x100 or 0xAFF (10E-1) Likewise 5 could be represented as 5e0, 50e-1, 0.5e1 and so forth.
This is a no-operation, as Decimals are Longs. However, the Frege compiler sees them as totally unrelated types (and rightly so).
The canonical Decimal 0