Expand description
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.
§Additional Features
For use with the bit manager crate, add this to your Cargo.toml
:
[features]
default = ["extended-rational/bit_manager_enabled"]
Macros§
- ratio
- A macro for creating a new signed rational using a given ratio or decimal
- uratio
- A macro for creating a new unsigned rational using a given ratio or decimal
Structs§
- Rational
- A type representing a signed projectively-extended rational number
- URational
- A type representing an unsigned projectively-extended rational number