Crate sp_arithmetic

source ·
Expand description

Minimal fixed point arithmetic primitives and types for runtime.

Re-exports§

Modules§

  • Infinite precision unsigned integer for substrate runtime.
  • Decimal Fixed Point implementations for Substrate runtime. Similar to types that implement PerThing, these are also fixed-point types, however, they are able to represent larger fractions:
  • 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.
  • Types that implement PerThing can be used as a floating-point alternative for numbers that operate within the realm of [0, 1]. The primary types may you encounter in Substrate would be the following:
  • Primitive traits for the runtime arithmetic.

Macros§

Enums§

Traits§

  • A collection-like object that is made of values of type T and can normalize its individual values around a centric point.
  • Trait for comparing two numbers with an threshold.

Functions§

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