Data.Float
No module comment.
The 64-bit IEEE 754 float, which the compiler provides.
The shortest decimal that parses back to the same Float; see
Data.Float.Text for the layout.
Accepts everything toString produces, Infinity and NaN included --
which matters because those two have no literal syntax, so parsing is the
only way to write them down. Correctly rounded: the nearest Float, ties
to even.
Total, but exact only to 2^53; past that it rounds to nearest, ties to even. Not a widening conversion, whatever the names suggest.
None for NaN, either infinity, and anything whose truncation falls
outside Int. The Option is not fussiness: out of range, fcvtzs
saturates to the nearest Int and a NaN becomes 0, so an unchecked version
would answer a number the value does not truncate to.
Clears the sign bit, so abs(-0.0) is 0.0 and abs(NaN) is a NaN. Not
written as if x < 0 -- that comparison is false for NaN and for -0.0.
The raw bit pattern. This is the only way to observe a NaN payload or
tell 0.0 from -0.0; nothing else in the language distinguishes them,
and there is deliberately no Hash Float built on it.
C's fmod (the remainder of truncating division) and IEEE's remainder
(of round-to-nearest division) disagree, and neither deserves the %
operator, so there is no Rem Float and both are spelled out.
Eq Float and Ord Float are the IEEE comparison predicates, and they are
the one pair of instances in the language that does not satisfy its class's
laws: Eq is not reflexive (NaN != NaN) and Ord is not total (every
comparison with NaN is false). Turkey has one Ord and no PartialOrd
split, so there is nowhere in the type system to put the distinction; it is
written down here instead.
Every one of the four Ord methods is overridden. Inheriting the defaults
would derive gte(x, y) as !lt(x, y), which makes gte(NaN, 1.0) true
while lte(NaN, 1.0) is false -- neither IEEE nor anything else.
IEEE division: zero divisors give infinities and NaN, never a panic.