[][src]Crate decorum

Making floating-point behave: ordering, equivalence, hashing, and constraints for floating-point types.

Decorum provides traits that describe types using floating-point representations and provides proxy types that wrap primitive floating-point types in order to implement a total ordering and various numeric traits. These proxy types also support constraints on the class of values they may represent, conditionally implementing traits and panicing if constraints are violated.

Total Ordering

The following total ordering is implemented by proxy types and is exposed by traits in the cmp module:

$$-\infin<\cdots<0<\cdots<\infin<\text{NaN}$$

Note that all zero and NaN representations are considered equivalent. See the cmp module documentation for more details.

Constraints

The NotNan and Finite types wrap primitive floating-point values and disallow values that represent NaN, $\infin$, and $-\infin$. Operations that emit values that violate these constraints will panic. The Total type applies no constraints.

Modules

cmp

Ordering and comparisons.

hash

Hashing.

Structs

ConstrainedFloat

Floating-point proxy that provides total ordering, hashing, and constraints.

Traits

Encoding

Floating-point encoding.

Infinite

Types that can represent infinities.

Nan

Floating-point representations that can be NaN.

Primitive

Primitive floating-point types.

Real

Types that can represent real numbers.

ToCanonicalBits

Converts floating-point values into a canonicalized form.

Type Definitions

Finite

Floating-point representation that must be a real number.

N32

32-bit floating-point representation that cannot be NaN.

N64

64-bit floating-point representation that cannot be NaN.

NotNan

Floating-point representation that cannot be NaN.

R32

32-bit floating-point representation that must be a real number.

R64

64-bit floating-point representation that must be a real number.

Total

Floating-point representation with total ordering.