Provides implementations of high-accuracy projectively-extended rational numbers and macros for creating them
Projectively-extended rationals differ from normal rationals because they have
a single, signless infinity and a single, signless zero. This means that 1/0
can be defined as equal to ∞
and 1/∞
equal to 0
.
Infinity
For unsigned numbers, ∞
is greater than every number, whereas with signed numbers,
∞
is not comparable to any number but itself. This is because ∞
equals -∞
so no
ordering can exist.
NaN
∞ + ∞
, ∞ - ∞
, ∞ * 0
, 0 * ∞
, ∞ / ∞
, and 0 / 0
are all NaN
A value of NaN
in any operation always returns NaN
. NaN
is not ordered and
is not equal to any number, including itself.
Panics
No operation should ever panic. Operations that overflow round each input to a
simpler fraction until they can succeed. Any invalid operations should
return NaN
instead of panicking.