Crate sp_arithmetic[][src]

Minimal fixed point arithmetic primitives and types for runtime.

Modules

biguint

Infinite precision unsigned integer for substrate runtime.

helpers_128bit

Some helper functions to work with 128bit numbers. Note that the functionality provided here is only sensible to use with 128bit numbers because for smaller sizes, you can always rely on assumptions of a bigger type (u128) being available, or simply create a per-thing and use the multiplication implementation provided there.

traits

Primitive traits for the runtime arithmetic.

Macros

assert_eq_error_rate

Copied from sp-runtime and documented there.

Structs

FixedI64

A fixed point number representation in the range.

FixedI128

A fixed point number representation in the range.

FixedU128

A fixed point number representation in the range.

PerU16

A fixed point representation of a number in the range [0, 1].

Perbill

A fixed point representation of a number in the range [0, 1].

Percent

A fixed point representation of a number in the range [0, 1].

Permill

A fixed point representation of a number in the range [0, 1].

Perquintill

A fixed point representation of a number in the range [0, 1].

Rational128

A wrapper for any rational number with a 128 bit numerator and denominator.

Traits

FixedPointNumber

Something that implements a decimal fixed point number.

FixedPointOperand

Integer types that can be used to interact with FixedPointNumber implementations.

Normalizable

A collection-like object that is made of values of type T and can normalize its individual values around a centric point.

PerThing

Something that implements a fixed point ration with an arbitrary granularity X, as parts per X.

ThresholdOrd

Trait for comparing two numbers with an threshold.

Functions

normalize

Normalize input so that the sum of all elements reaches targeted_sum.

Type Definitions

InnerOf

Get the inner type of a PerThing.

UpperOf

Get the upper type of a PerThing.