Crate const_fixedp[][src]

Expand description

Basic unsigned fixed-point arithmetic.

This module provides a Copy type that holds arbitrary precision for fractional values, performs additions and subtractions, and can be compared and sorted efficiently.

The internal representation uses 64 bits, and will adapt to the requested precision by reducing the integer range, so keep this in mind when increasing precision but still requiring big values, as compilation will fail if there’s not enough bit space for at least FixedP::<P>::MIN_UNIT_SCALE integer values.

Enable the serde feature flag to have serialization and deserialization capabilities for this type.

Macros

Assert a boolean condition in constant contexts. Signal a fatal error on failure.

Cast a given integer type to another one in constant contexts. Signal a fatal error if the cast target can’t fit the source integer type.

Unwrap an Option in constant contexts. Signal a fatal error on None.

Signal a fatal error when evaluating a constant context.

Unwrap a Result<T, E> in constant contexts. Signal a fatal error on Err.

Structs

A Copy type representing an unsigned, fixed point value, supporting const context evaluation.

Enums

An error type covering the cases where units or fractional values are out of range, when a conversion error happens (ie. trying to convert from a negative or too big value), or when parsing fails.

Type Definitions

Type describing the precision required for the fractional part of a fixed-point value.