Struct fixnum::FixedPoint

source ·
#[repr(transparent)]
pub struct FixedPoint<I, P> { /* private fields */ }
Available on crate features i128 or i64 or i32 or i16 only.
Expand description

Abstraction over fixed point numbers of arbitrary (but only compile-time specified) size and precision.

The internal representation is a fixed point decimal number, an integer value pre-multiplied by 10 ^ PRECISION, where PRECISION is a compile-time-defined decimal places count.

Maximal possible value: MAX = (2 ^ (BITS_COUNT - 1) - 1) / 10 ^ PRECISION Maximal possible calculation error: ERROR_MAX = 0.5 / (10 ^ PRECISION)

E.g. for i64 with 9 decimal places:

MAX = (2 ^ (64 - 1) - 1) / 1e9 = 9223372036.854775807 ~ 9.2e9
ERROR_MAX = 0.5 / 1e9 = 5e-10

Implementations§

source§

impl<P: Precision> FixedPoint<i16, P>

source

pub fn from_str_exact(str: &str) -> Result<Self, ConvertError>

Parses a string slice into a fixed point. If the value cannot be represented then this will return an error.

Use the FromStr instance to parse with rounding.

source§

impl<P: Precision> FixedPoint<i32, P>

source

pub fn from_str_exact(str: &str) -> Result<Self, ConvertError>

Parses a string slice into a fixed point. If the value cannot be represented then this will return an error.

Use the FromStr instance to parse with rounding.

source§

impl<P: Precision> FixedPoint<i64, P>

source

pub fn from_str_exact(str: &str) -> Result<Self, ConvertError>

Parses a string slice into a fixed point. If the value cannot be represented then this will return an error.

Use the FromStr instance to parse with rounding.

source§

impl<P: Precision> FixedPoint<i128, P>

source

pub fn from_str_exact(str: &str) -> Result<Self, ConvertError>

Parses a string slice into a fixed point. If the value cannot be represented then this will return an error.

Use the FromStr instance to parse with rounding.

source§

impl<I, P> FixedPoint<I, P>

source

pub const fn from_bits(raw: I) -> Self

Creates from the raw representation. 1 here is equal to 1**-P

source

pub const fn as_bits(&self) -> &I

Returns the raw representation.

source

pub fn into_bits(self) -> I

Converts to the raw representation.

source§

impl<P: Precision> FixedPoint<i16, P>

source

pub const PRECISION: i32 = P::I32

Available on crate feature i16 only.

The number of digits in the fractional part.

source

pub const EPSILON: Self = _

Available on crate feature i16 only.

The difference between 0.0 and the next larger representable number.

source§

impl<P: Precision> FixedPoint<i16, P>

source

pub fn signum(self) -> i16

Available on crate feature i16 only.

Returns a number representing sign of self.

  • 0 if the number is zero
  • 1 if the number is positive
  • -1 if the number is negative
source

pub fn recip(self, mode: RoundMode) -> Result<Self, ArithmeticError>

Available on crate feature i16 only.

Returns 1/n.

source

pub fn cneg(self) -> Result<Self, ArithmeticError>

Available on crate feature i16 only.

Checked negation. Returns Err on overflow (you can’t negate MIN value).

source

pub fn half_sum(a: Self, b: Self, mode: RoundMode) -> Self

Available on crate feature i16 only.

Calculates (a + b) / 2.

source

pub fn integral(self, mode: RoundMode) -> i16

Available on crate feature i16 only.

Takes rounded integral part of the number.

use fixnum::{FixedPoint, typenum::U9, ops::RoundMode::*};

type Amount = FixedPoint<i64, U9>;

let a: Amount = "8273.519".parse()?;
assert_eq!(a.integral(Floor), 8273);
assert_eq!(a.integral(Nearest), 8274);
assert_eq!(a.integral(Ceil), 8274);

let a: Amount = "-8273.519".parse()?;
assert_eq!(a.integral(Floor), -8274);
assert_eq!(a.integral(Nearest), -8274);
assert_eq!(a.integral(Ceil), -8273);
source

pub fn floor(self) -> Self

Available on crate feature i16 only.

Returns the largest integer less than or equal to a number.

source

pub fn ceil(self) -> Self

Available on crate feature i16 only.

Returns the smallest integer greater than or equal to a number.

source

pub fn round(self) -> Self

Available on crate feature i16 only.

Returns the nearest integer to a number. Round half-way cases away from 0.0.

source

pub fn round_towards_zero_by(self, precision: Self) -> Self

Available on crate feature i16 only.

Rounds towards zero by the provided precision.

source

pub fn next_power_of_ten(self) -> Result<Self, ArithmeticError>

Available on crate feature i16 only.

Returns the next power of ten:

  • For positive: the smallest greater than or equal to a number.
  • For negative: the largest less than or equal to a number.
source

pub fn abs(self) -> Result<Self, ArithmeticError>

Available on crate feature i16 only.

Returns the absolute value of a number.

source

pub fn rsqrt(self, mode: RoundMode) -> Result<Self, ArithmeticError>

Available on crate feature i16 only.

Checked rounding square root. Returns Err for negative argument.

Square root of a non-negative F is a non-negative S such that:

  • Floor: S ≤ sqrt(F)
  • Ceil: S ≥ sqrt(F)
  • Nearest: Floor or Ceil, which one is closer to sqrt(F)

The fastest mode is Floor.

use fixnum::{ArithmeticError, FixedPoint, typenum::U9};
use fixnum::ops::{Zero, RoundMode::*};

type Amount = FixedPoint<i64, U9>;

let a: Amount = "81".parse()?;
let b: Amount = "2".parse()?;
let c: Amount = "-100".parse()?;
assert_eq!(a.rsqrt(Floor)?, "9".parse()?);
assert_eq!(b.rsqrt(Floor)?, "1.414213562".parse()?);
assert_eq!(b.rsqrt(Ceil)?, "1.414213563".parse()?);
assert_eq!(c.rsqrt(Floor), Err(ArithmeticError::DomainViolation));
source§

impl<P: Precision> FixedPoint<i16, P>

source

pub fn from_decimal(mantissa: i16, exponent: i32) -> Result<Self, ConvertError>

Available on crate feature i16 only.

Creates a new number from separate mantissa and exponent.

source

pub fn to_decimal(&self, max_exponent: i32) -> (i16, i32)

Available on crate feature i16 only.

Returns a pair (mantissa, exponent) where exponent is in [-PRECISION, max_exponent].

Examples:

  • fp!(5.5).to_decimal(0) // => (55, -1)
  • fp!(5.5).to_decimal(-1) // => (55, -1)
  • fp!(5.5).to_decimal(-2) // => (550, -2)
  • fp!(50).to_decimal(0) // => (50, 0)
  • fp!(50).to_decimal(i32::MAX) // => (5, 1)
Panics

If max_exponent is less than -PRECISION.

source§

impl<P: Precision> FixedPoint<i32, P>

source

pub const PRECISION: i32 = P::I32

Available on crate feature i32 only.

The number of digits in the fractional part.

source

pub const EPSILON: Self = _

Available on crate feature i32 only.

The difference between 0.0 and the next larger representable number.

source§

impl<P: Precision> FixedPoint<i32, P>

source

pub fn signum(self) -> i32

Available on crate feature i32 only.

Returns a number representing sign of self.

  • 0 if the number is zero
  • 1 if the number is positive
  • -1 if the number is negative
source

pub fn recip(self, mode: RoundMode) -> Result<Self, ArithmeticError>

Available on crate feature i32 only.

Returns 1/n.

source

pub fn cneg(self) -> Result<Self, ArithmeticError>

Available on crate feature i32 only.

Checked negation. Returns Err on overflow (you can’t negate MIN value).

source

pub fn half_sum(a: Self, b: Self, mode: RoundMode) -> Self

Available on crate feature i32 only.

Calculates (a + b) / 2.

source

pub fn integral(self, mode: RoundMode) -> i32

Available on crate feature i32 only.

Takes rounded integral part of the number.

use fixnum::{FixedPoint, typenum::U9, ops::RoundMode::*};

type Amount = FixedPoint<i64, U9>;

let a: Amount = "8273.519".parse()?;
assert_eq!(a.integral(Floor), 8273);
assert_eq!(a.integral(Nearest), 8274);
assert_eq!(a.integral(Ceil), 8274);

let a: Amount = "-8273.519".parse()?;
assert_eq!(a.integral(Floor), -8274);
assert_eq!(a.integral(Nearest), -8274);
assert_eq!(a.integral(Ceil), -8273);
source

pub fn floor(self) -> Self

Available on crate feature i32 only.

Returns the largest integer less than or equal to a number.

source

pub fn ceil(self) -> Self

Available on crate feature i32 only.

Returns the smallest integer greater than or equal to a number.

source

pub fn round(self) -> Self

Available on crate feature i32 only.

Returns the nearest integer to a number. Round half-way cases away from 0.0.

source

pub fn round_towards_zero_by(self, precision: Self) -> Self

Available on crate feature i32 only.

Rounds towards zero by the provided precision.

source

pub fn next_power_of_ten(self) -> Result<Self, ArithmeticError>

Available on crate feature i32 only.

Returns the next power of ten:

  • For positive: the smallest greater than or equal to a number.
  • For negative: the largest less than or equal to a number.
source

pub fn abs(self) -> Result<Self, ArithmeticError>

Available on crate feature i32 only.

Returns the absolute value of a number.

source

pub fn rsqrt(self, mode: RoundMode) -> Result<Self, ArithmeticError>

Available on crate feature i32 only.

Checked rounding square root. Returns Err for negative argument.

Square root of a non-negative F is a non-negative S such that:

  • Floor: S ≤ sqrt(F)
  • Ceil: S ≥ sqrt(F)
  • Nearest: Floor or Ceil, which one is closer to sqrt(F)

The fastest mode is Floor.

use fixnum::{ArithmeticError, FixedPoint, typenum::U9};
use fixnum::ops::{Zero, RoundMode::*};

type Amount = FixedPoint<i64, U9>;

let a: Amount = "81".parse()?;
let b: Amount = "2".parse()?;
let c: Amount = "-100".parse()?;
assert_eq!(a.rsqrt(Floor)?, "9".parse()?);
assert_eq!(b.rsqrt(Floor)?, "1.414213562".parse()?);
assert_eq!(b.rsqrt(Ceil)?, "1.414213563".parse()?);
assert_eq!(c.rsqrt(Floor), Err(ArithmeticError::DomainViolation));
source§

impl<P: Precision> FixedPoint<i32, P>

source

pub fn from_decimal(mantissa: i32, exponent: i32) -> Result<Self, ConvertError>

Available on crate feature i32 only.

Creates a new number from separate mantissa and exponent.

source

pub fn to_decimal(&self, max_exponent: i32) -> (i32, i32)

Available on crate feature i32 only.

Returns a pair (mantissa, exponent) where exponent is in [-PRECISION, max_exponent].

Examples:

  • fp!(5.5).to_decimal(0) // => (55, -1)
  • fp!(5.5).to_decimal(-1) // => (55, -1)
  • fp!(5.5).to_decimal(-2) // => (550, -2)
  • fp!(50).to_decimal(0) // => (50, 0)
  • fp!(50).to_decimal(i32::MAX) // => (5, 1)
Panics

If max_exponent is less than -PRECISION.

source§

impl<P: Precision> FixedPoint<i64, P>

source

pub const PRECISION: i32 = P::I32

Available on crate feature i64 only.

The number of digits in the fractional part.

source

pub const EPSILON: Self = _

Available on crate feature i64 only.

The difference between 0.0 and the next larger representable number.

source§

impl<P: Precision> FixedPoint<i64, P>

source

pub fn signum(self) -> i64

Available on crate feature i64 only.

Returns a number representing sign of self.

  • 0 if the number is zero
  • 1 if the number is positive
  • -1 if the number is negative
source

pub fn recip(self, mode: RoundMode) -> Result<Self, ArithmeticError>

Available on crate feature i64 only.

Returns 1/n.

source

pub fn cneg(self) -> Result<Self, ArithmeticError>

Available on crate feature i64 only.

Checked negation. Returns Err on overflow (you can’t negate MIN value).

source

pub fn half_sum(a: Self, b: Self, mode: RoundMode) -> Self

Available on crate feature i64 only.

Calculates (a + b) / 2.

source

pub fn integral(self, mode: RoundMode) -> i64

Available on crate feature i64 only.

Takes rounded integral part of the number.

use fixnum::{FixedPoint, typenum::U9, ops::RoundMode::*};

type Amount = FixedPoint<i64, U9>;

let a: Amount = "8273.519".parse()?;
assert_eq!(a.integral(Floor), 8273);
assert_eq!(a.integral(Nearest), 8274);
assert_eq!(a.integral(Ceil), 8274);

let a: Amount = "-8273.519".parse()?;
assert_eq!(a.integral(Floor), -8274);
assert_eq!(a.integral(Nearest), -8274);
assert_eq!(a.integral(Ceil), -8273);
source

pub fn floor(self) -> Self

Available on crate feature i64 only.

Returns the largest integer less than or equal to a number.

source

pub fn ceil(self) -> Self

Available on crate feature i64 only.

Returns the smallest integer greater than or equal to a number.

source

pub fn round(self) -> Self

Available on crate feature i64 only.

Returns the nearest integer to a number. Round half-way cases away from 0.0.

source

pub fn round_towards_zero_by(self, precision: Self) -> Self

Available on crate feature i64 only.

Rounds towards zero by the provided precision.

source

pub fn next_power_of_ten(self) -> Result<Self, ArithmeticError>

Available on crate feature i64 only.

Returns the next power of ten:

  • For positive: the smallest greater than or equal to a number.
  • For negative: the largest less than or equal to a number.
source

pub fn abs(self) -> Result<Self, ArithmeticError>

Available on crate feature i64 only.

Returns the absolute value of a number.

source

pub fn rsqrt(self, mode: RoundMode) -> Result<Self, ArithmeticError>

Available on crate feature i64 only.

Checked rounding square root. Returns Err for negative argument.

Square root of a non-negative F is a non-negative S such that:

  • Floor: S ≤ sqrt(F)
  • Ceil: S ≥ sqrt(F)
  • Nearest: Floor or Ceil, which one is closer to sqrt(F)

The fastest mode is Floor.

use fixnum::{ArithmeticError, FixedPoint, typenum::U9};
use fixnum::ops::{Zero, RoundMode::*};

type Amount = FixedPoint<i64, U9>;

let a: Amount = "81".parse()?;
let b: Amount = "2".parse()?;
let c: Amount = "-100".parse()?;
assert_eq!(a.rsqrt(Floor)?, "9".parse()?);
assert_eq!(b.rsqrt(Floor)?, "1.414213562".parse()?);
assert_eq!(b.rsqrt(Ceil)?, "1.414213563".parse()?);
assert_eq!(c.rsqrt(Floor), Err(ArithmeticError::DomainViolation));
source§

impl<P: Precision> FixedPoint<i64, P>

source

pub fn from_decimal(mantissa: i64, exponent: i32) -> Result<Self, ConvertError>

Available on crate feature i64 only.

Creates a new number from separate mantissa and exponent.

source

pub fn to_decimal(&self, max_exponent: i32) -> (i64, i32)

Available on crate feature i64 only.

Returns a pair (mantissa, exponent) where exponent is in [-PRECISION, max_exponent].

Examples:

  • fp!(5.5).to_decimal(0) // => (55, -1)
  • fp!(5.5).to_decimal(-1) // => (55, -1)
  • fp!(5.5).to_decimal(-2) // => (550, -2)
  • fp!(50).to_decimal(0) // => (50, 0)
  • fp!(50).to_decimal(i32::MAX) // => (5, 1)
Panics

If max_exponent is less than -PRECISION.

source§

impl<P: Precision> FixedPoint<i128, P>

source

pub const PRECISION: i32 = P::I32

Available on crate feature i128 only.

The number of digits in the fractional part.

source

pub const EPSILON: Self = _

Available on crate feature i128 only.

The difference between 0.0 and the next larger representable number.

source§

impl<P: Precision> FixedPoint<i128, P>

source

pub fn signum(self) -> i128

Available on crate feature i128 only.

Returns a number representing sign of self.

  • 0 if the number is zero
  • 1 if the number is positive
  • -1 if the number is negative
source

pub fn recip(self, mode: RoundMode) -> Result<Self, ArithmeticError>

Available on crate feature i128 only.

Returns 1/n.

source

pub fn cneg(self) -> Result<Self, ArithmeticError>

Available on crate feature i128 only.

Checked negation. Returns Err on overflow (you can’t negate MIN value).

source

pub fn half_sum(a: Self, b: Self, mode: RoundMode) -> Self

Available on crate feature i128 only.

Calculates (a + b) / 2.

source

pub fn integral(self, mode: RoundMode) -> i128

Available on crate feature i128 only.

Takes rounded integral part of the number.

use fixnum::{FixedPoint, typenum::U9, ops::RoundMode::*};

type Amount = FixedPoint<i64, U9>;

let a: Amount = "8273.519".parse()?;
assert_eq!(a.integral(Floor), 8273);
assert_eq!(a.integral(Nearest), 8274);
assert_eq!(a.integral(Ceil), 8274);

let a: Amount = "-8273.519".parse()?;
assert_eq!(a.integral(Floor), -8274);
assert_eq!(a.integral(Nearest), -8274);
assert_eq!(a.integral(Ceil), -8273);
source

pub fn floor(self) -> Self

Available on crate feature i128 only.

Returns the largest integer less than or equal to a number.

source

pub fn ceil(self) -> Self

Available on crate feature i128 only.

Returns the smallest integer greater than or equal to a number.

source

pub fn round(self) -> Self

Available on crate feature i128 only.

Returns the nearest integer to a number. Round half-way cases away from 0.0.

source

pub fn round_towards_zero_by(self, precision: Self) -> Self

Available on crate feature i128 only.

Rounds towards zero by the provided precision.

source

pub fn next_power_of_ten(self) -> Result<Self, ArithmeticError>

Available on crate feature i128 only.

Returns the next power of ten:

  • For positive: the smallest greater than or equal to a number.
  • For negative: the largest less than or equal to a number.
source

pub fn abs(self) -> Result<Self, ArithmeticError>

Available on crate feature i128 only.

Returns the absolute value of a number.

source

pub fn rsqrt(self, mode: RoundMode) -> Result<Self, ArithmeticError>

Available on crate feature i128 only.

Checked rounding square root. Returns Err for negative argument.

Square root of a non-negative F is a non-negative S such that:

  • Floor: S ≤ sqrt(F)
  • Ceil: S ≥ sqrt(F)
  • Nearest: Floor or Ceil, which one is closer to sqrt(F)

The fastest mode is Floor.

use fixnum::{ArithmeticError, FixedPoint, typenum::U9};
use fixnum::ops::{Zero, RoundMode::*};

type Amount = FixedPoint<i64, U9>;

let a: Amount = "81".parse()?;
let b: Amount = "2".parse()?;
let c: Amount = "-100".parse()?;
assert_eq!(a.rsqrt(Floor)?, "9".parse()?);
assert_eq!(b.rsqrt(Floor)?, "1.414213562".parse()?);
assert_eq!(b.rsqrt(Ceil)?, "1.414213563".parse()?);
assert_eq!(c.rsqrt(Floor), Err(ArithmeticError::DomainViolation));
source§

impl<P: Precision> FixedPoint<i128, P>

source

pub fn from_decimal(mantissa: i128, exponent: i32) -> Result<Self, ConvertError>

Available on crate feature i128 only.

Creates a new number from separate mantissa and exponent.

source

pub fn to_decimal(&self, max_exponent: i32) -> (i128, i32)

Available on crate feature i128 only.

Returns a pair (mantissa, exponent) where exponent is in [-PRECISION, max_exponent].

Examples:

  • fp!(5.5).to_decimal(0) // => (55, -1)
  • fp!(5.5).to_decimal(-1) // => (55, -1)
  • fp!(5.5).to_decimal(-2) // => (550, -2)
  • fp!(50).to_decimal(0) // => (50, 0)
  • fp!(50).to_decimal(i32::MAX) // => (5, 1)
Panics

If max_exponent is less than -PRECISION.

Trait Implementations§

source§

impl<P: Precision> Bounded for FixedPoint<i128, P>

Available on crate feature i128 only.
source§

const MIN: Self = _

Represents MIN.
source§

const MAX: Self = _

Represents MAX.
source§

impl<P: Precision> Bounded for FixedPoint<i16, P>

Available on crate feature i16 only.
source§

const MIN: Self = _

Represents MIN.
source§

const MAX: Self = _

Represents MAX.
source§

impl<P: Precision> Bounded for FixedPoint<i32, P>

Available on crate feature i32 only.
source§

const MIN: Self = _

Represents MIN.
source§

const MAX: Self = _

Represents MAX.
source§

impl<P: Precision> Bounded for FixedPoint<i64, P>

Available on crate feature i64 only.
source§

const MIN: Self = _

Represents MIN.
source§

const MAX: Self = _

Represents MAX.
source§

impl<P: Precision> CheckedAdd<FixedPoint<i128, P>> for FixedPoint<i128, P>

Available on crate feature i128 only.
§

type Output = FixedPoint<i128, P>

Result of addition.
§

type Error = ArithmeticError

source§

fn cadd(self, rhs: Self) -> Result<Self, ArithmeticError>

Checked addition. Returns Err on overflow. Read more
source§

fn saturating_add(self, rhs: Self) -> Self::Output

Saturating addition. Computes self + rhs, saturating at the numeric bounds (MIN, MAX) instead of overflowing. Read more
source§

impl<P: Precision> CheckedAdd<FixedPoint<i16, P>> for FixedPoint<i16, P>

Available on crate feature i16 only.
§

type Output = FixedPoint<i16, P>

Result of addition.
§

type Error = ArithmeticError

source§

fn cadd(self, rhs: Self) -> Result<Self, ArithmeticError>

Checked addition. Returns Err on overflow. Read more
source§

fn saturating_add(self, rhs: Self) -> Self::Output

Saturating addition. Computes self + rhs, saturating at the numeric bounds (MIN, MAX) instead of overflowing. Read more
source§

impl<P: Precision> CheckedAdd<FixedPoint<i32, P>> for FixedPoint<i32, P>

Available on crate feature i32 only.
§

type Output = FixedPoint<i32, P>

Result of addition.
§

type Error = ArithmeticError

source§

fn cadd(self, rhs: Self) -> Result<Self, ArithmeticError>

Checked addition. Returns Err on overflow. Read more
source§

fn saturating_add(self, rhs: Self) -> Self::Output

Saturating addition. Computes self + rhs, saturating at the numeric bounds (MIN, MAX) instead of overflowing. Read more
source§

impl<P: Precision> CheckedAdd<FixedPoint<i64, P>> for FixedPoint<i64, P>

Available on crate feature i64 only.
§

type Output = FixedPoint<i64, P>

Result of addition.
§

type Error = ArithmeticError

source§

fn cadd(self, rhs: Self) -> Result<Self, ArithmeticError>

Checked addition. Returns Err on overflow. Read more
source§

fn saturating_add(self, rhs: Self) -> Self::Output

Saturating addition. Computes self + rhs, saturating at the numeric bounds (MIN, MAX) instead of overflowing. Read more
source§

impl<P: Precision> CheckedMul<FixedPoint<i128, P>> for i128

Available on crate feature i128 only.
§

type Output = FixedPoint<i128, P>

Result of multiplication.
§

type Error = ArithmeticError

source§

fn cmul( self, rhs: FixedPoint<i128, P> ) -> Result<FixedPoint<i128, P>, ArithmeticError>

Checked multiplication. Returns Err on overflow. This is multiplication without rounding, hence it’s available only when at least one operand is integer. Read more
source§

fn saturating_mul(self, rhs: FixedPoint<i128, P>) -> Self::Output

Saturating multiplication. Computes self * rhs, saturating at the numeric bounds (MIN, MAX) instead of overflowing. This is multiplication without rounding, hence it’s available only when at least one operand is integer. Read more
source§

impl<P: Precision> CheckedMul<FixedPoint<i16, P>> for i16

Available on crate feature i16 only.
§

type Output = FixedPoint<i16, P>

Result of multiplication.
§

type Error = ArithmeticError

source§

fn cmul( self, rhs: FixedPoint<i16, P> ) -> Result<FixedPoint<i16, P>, ArithmeticError>

Checked multiplication. Returns Err on overflow. This is multiplication without rounding, hence it’s available only when at least one operand is integer. Read more
source§

fn saturating_mul(self, rhs: FixedPoint<i16, P>) -> Self::Output

Saturating multiplication. Computes self * rhs, saturating at the numeric bounds (MIN, MAX) instead of overflowing. This is multiplication without rounding, hence it’s available only when at least one operand is integer. Read more
source§

impl<P: Precision> CheckedMul<FixedPoint<i32, P>> for i32

Available on crate feature i32 only.
§

type Output = FixedPoint<i32, P>

Result of multiplication.
§

type Error = ArithmeticError

source§

fn cmul( self, rhs: FixedPoint<i32, P> ) -> Result<FixedPoint<i32, P>, ArithmeticError>

Checked multiplication. Returns Err on overflow. This is multiplication without rounding, hence it’s available only when at least one operand is integer. Read more
source§

fn saturating_mul(self, rhs: FixedPoint<i32, P>) -> Self::Output

Saturating multiplication. Computes self * rhs, saturating at the numeric bounds (MIN, MAX) instead of overflowing. This is multiplication without rounding, hence it’s available only when at least one operand is integer. Read more
source§

impl<P: Precision> CheckedMul<FixedPoint<i64, P>> for i64

Available on crate feature i64 only.
§

type Output = FixedPoint<i64, P>

Result of multiplication.
§

type Error = ArithmeticError

source§

fn cmul( self, rhs: FixedPoint<i64, P> ) -> Result<FixedPoint<i64, P>, ArithmeticError>

Checked multiplication. Returns Err on overflow. This is multiplication without rounding, hence it’s available only when at least one operand is integer. Read more
source§

fn saturating_mul(self, rhs: FixedPoint<i64, P>) -> Self::Output

Saturating multiplication. Computes self * rhs, saturating at the numeric bounds (MIN, MAX) instead of overflowing. This is multiplication without rounding, hence it’s available only when at least one operand is integer. Read more
source§

impl<P: Precision> CheckedMul<i128> for FixedPoint<i128, P>

Available on crate feature i128 only.
§

type Output = FixedPoint<i128, P>

Result of multiplication.
§

type Error = ArithmeticError

source§

fn cmul(self, rhs: i128) -> Result<Self, ArithmeticError>

Checked multiplication. Returns Err on overflow. This is multiplication without rounding, hence it’s available only when at least one operand is integer. Read more
source§

fn saturating_mul(self, rhs: i128) -> Self::Output

Saturating multiplication. Computes self * rhs, saturating at the numeric bounds (MIN, MAX) instead of overflowing. This is multiplication without rounding, hence it’s available only when at least one operand is integer. Read more
source§

impl<P: Precision> CheckedMul<i16> for FixedPoint<i16, P>

Available on crate feature i16 only.
§

type Output = FixedPoint<i16, P>

Result of multiplication.
§

type Error = ArithmeticError

source§

fn cmul(self, rhs: i16) -> Result<Self, ArithmeticError>

Checked multiplication. Returns Err on overflow. This is multiplication without rounding, hence it’s available only when at least one operand is integer. Read more
source§

fn saturating_mul(self, rhs: i16) -> Self::Output

Saturating multiplication. Computes self * rhs, saturating at the numeric bounds (MIN, MAX) instead of overflowing. This is multiplication without rounding, hence it’s available only when at least one operand is integer. Read more
source§

impl<P: Precision> CheckedMul<i32> for FixedPoint<i32, P>

Available on crate feature i32 only.
§

type Output = FixedPoint<i32, P>

Result of multiplication.
§

type Error = ArithmeticError

source§

fn cmul(self, rhs: i32) -> Result<Self, ArithmeticError>

Checked multiplication. Returns Err on overflow. This is multiplication without rounding, hence it’s available only when at least one operand is integer. Read more
source§

fn saturating_mul(self, rhs: i32) -> Self::Output

Saturating multiplication. Computes self * rhs, saturating at the numeric bounds (MIN, MAX) instead of overflowing. This is multiplication without rounding, hence it’s available only when at least one operand is integer. Read more
source§

impl<P: Precision> CheckedMul<i64> for FixedPoint<i64, P>

Available on crate feature i64 only.
§

type Output = FixedPoint<i64, P>

Result of multiplication.
§

type Error = ArithmeticError

source§

fn cmul(self, rhs: i64) -> Result<Self, ArithmeticError>

Checked multiplication. Returns Err on overflow. This is multiplication without rounding, hence it’s available only when at least one operand is integer. Read more
source§

fn saturating_mul(self, rhs: i64) -> Self::Output

Saturating multiplication. Computes self * rhs, saturating at the numeric bounds (MIN, MAX) instead of overflowing. This is multiplication without rounding, hence it’s available only when at least one operand is integer. Read more
source§

impl<P: Precision> CheckedSub<FixedPoint<i128, P>> for FixedPoint<i128, P>

Available on crate feature i128 only.
§

type Output = FixedPoint<i128, P>

Result of subtraction.
§

type Error = ArithmeticError

source§

fn csub(self, rhs: Self) -> Result<Self, ArithmeticError>

Checked subtraction. Returns Err on overflow. Read more
source§

fn saturating_sub(self, rhs: Self) -> Self::Output

Saturating subtraction. Computes self - rhs, saturating at the numeric bounds (MIN, MAX) instead of overflowing. Read more
source§

impl<P: Precision> CheckedSub<FixedPoint<i16, P>> for FixedPoint<i16, P>

Available on crate feature i16 only.
§

type Output = FixedPoint<i16, P>

Result of subtraction.
§

type Error = ArithmeticError

source§

fn csub(self, rhs: Self) -> Result<Self, ArithmeticError>

Checked subtraction. Returns Err on overflow. Read more
source§

fn saturating_sub(self, rhs: Self) -> Self::Output

Saturating subtraction. Computes self - rhs, saturating at the numeric bounds (MIN, MAX) instead of overflowing. Read more
source§

impl<P: Precision> CheckedSub<FixedPoint<i32, P>> for FixedPoint<i32, P>

Available on crate feature i32 only.
§

type Output = FixedPoint<i32, P>

Result of subtraction.
§

type Error = ArithmeticError

source§

fn csub(self, rhs: Self) -> Result<Self, ArithmeticError>

Checked subtraction. Returns Err on overflow. Read more
source§

fn saturating_sub(self, rhs: Self) -> Self::Output

Saturating subtraction. Computes self - rhs, saturating at the numeric bounds (MIN, MAX) instead of overflowing. Read more
source§

impl<P: Precision> CheckedSub<FixedPoint<i64, P>> for FixedPoint<i64, P>

Available on crate feature i64 only.
§

type Output = FixedPoint<i64, P>

Result of subtraction.
§

type Error = ArithmeticError

source§

fn csub(self, rhs: Self) -> Result<Self, ArithmeticError>

Checked subtraction. Returns Err on overflow. Read more
source§

fn saturating_sub(self, rhs: Self) -> Self::Output

Saturating subtraction. Computes self - rhs, saturating at the numeric bounds (MIN, MAX) instead of overflowing. Read more
source§

impl<I: Clone, P: Clone> Clone for FixedPoint<I, P>

source§

fn clone(&self) -> FixedPoint<I, P>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<P> CompactAs for FixedPoint<i128, P>

Available on crate features parity and i128 only.
§

type As = u128

A compact-encodable type that should be used as the encoding.
source§

fn encode_as(&self) -> &Self::As

Returns the compact-encodable type.
source§

fn decode_from(value: Self::As) -> Result<Self, Error>

Decode Self from the compact-decoded type.
source§

impl<P> CompactAs for FixedPoint<i16, P>

Available on crate features parity and i16 only.
§

type As = u16

A compact-encodable type that should be used as the encoding.
source§

fn encode_as(&self) -> &Self::As

Returns the compact-encodable type.
source§

fn decode_from(value: Self::As) -> Result<Self, Error>

Decode Self from the compact-decoded type.
source§

impl<P> CompactAs for FixedPoint<i32, P>

Available on crate features parity and i32 only.
§

type As = u32

A compact-encodable type that should be used as the encoding.
source§

fn encode_as(&self) -> &Self::As

Returns the compact-encodable type.
source§

fn decode_from(value: Self::As) -> Result<Self, Error>

Decode Self from the compact-decoded type.
source§

impl<P> CompactAs for FixedPoint<i64, P>

Available on crate features parity and i64 only.
§

type As = u64

A compact-encodable type that should be used as the encoding.
source§

fn encode_as(&self) -> &Self::As

Returns the compact-encodable type.
source§

fn decode_from(value: Self::As) -> Result<Self, Error>

Decode Self from the compact-decoded type.
source§

impl<P: Precision> Debug for FixedPoint<i128, P>

Available on crate feature i128 only.
source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<P: Precision> Debug for FixedPoint<i16, P>

Available on crate feature i16 only.
source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<P: Precision> Debug for FixedPoint<i32, P>

Available on crate feature i32 only.
source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<P: Precision> Debug for FixedPoint<i64, P>

Available on crate feature i64 only.
source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<P> Decode for FixedPoint<i128, P>

Available on crate features parity and i128 only.
source§

fn decode<In: Input>(input: &mut In) -> Result<Self, Error>

Attempt to deserialise the value from input.
source§

fn skip<I>(input: &mut I) -> Result<(), Error>where I: Input,

Attempt to skip the encoded value from input. Read more
source§

fn encoded_fixed_size() -> Option<usize>

Returns the fixed encoded size of the type. Read more
source§

impl<P> Decode for FixedPoint<i16, P>

Available on crate features parity and i16 only.
source§

fn decode<In: Input>(input: &mut In) -> Result<Self, Error>

Attempt to deserialise the value from input.
source§

fn skip<I>(input: &mut I) -> Result<(), Error>where I: Input,

Attempt to skip the encoded value from input. Read more
source§

fn encoded_fixed_size() -> Option<usize>

Returns the fixed encoded size of the type. Read more
source§

impl<P> Decode for FixedPoint<i32, P>

Available on crate features parity and i32 only.
source§

fn decode<In: Input>(input: &mut In) -> Result<Self, Error>

Attempt to deserialise the value from input.
source§

fn skip<I>(input: &mut I) -> Result<(), Error>where I: Input,

Attempt to skip the encoded value from input. Read more
source§

fn encoded_fixed_size() -> Option<usize>

Returns the fixed encoded size of the type. Read more
source§

impl<P> Decode for FixedPoint<i64, P>

Available on crate features parity and i64 only.
source§

fn decode<In: Input>(input: &mut In) -> Result<Self, Error>

Attempt to deserialise the value from input.
source§

fn skip<I>(input: &mut I) -> Result<(), Error>where I: Input,

Attempt to skip the encoded value from input. Read more
source§

fn encoded_fixed_size() -> Option<usize>

Returns the fixed encoded size of the type. Read more
source§

impl<I: Default, P: Default> Default for FixedPoint<I, P>

source§

fn default() -> FixedPoint<I, P>

Returns the “default value” for a type. Read more
source§

impl<'de, I, P> Deserialize<'de> for FixedPoint<I, P>where I: Deserialize<'de>, Self: FromStr + TryFrom<f64> + TryFrom<u64> + TryFrom<i64> + TryFrom<i128> + TryFrom<u128>,

Available on crate feature serde only.
source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<P: Precision> Display for FixedPoint<i128, P>

Available on crate feature i128 only.
source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<P: Precision> Display for FixedPoint<i16, P>

Available on crate feature i16 only.
source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<P: Precision> Display for FixedPoint<i32, P>

Available on crate feature i32 only.
source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<P: Precision> Display for FixedPoint<i64, P>

Available on crate feature i64 only.
source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<P> Encode for FixedPoint<i128, P>

Available on crate features parity and i128 only.
source§

fn encode_to<O: Output + ?Sized>(&self, destination: &mut O)

Convert self to a slice and append it to the destination.
source§

fn size_hint(&self) -> usize

If possible give a hint of expected size of the encoding. Read more
source§

fn encode(&self) -> Vec<u8, Global>

Convert self to an owned vector.
source§

fn using_encoded<R, F>(&self, f: F) -> Rwhere F: FnOnce(&[u8]) -> R,

Convert self to a slice and then invoke the given closure with it.
source§

fn encoded_size(&self) -> usize

Calculates the encoded size. Read more
source§

impl<P> Encode for FixedPoint<i16, P>

Available on crate features parity and i16 only.
source§

fn encode_to<O: Output + ?Sized>(&self, destination: &mut O)

Convert self to a slice and append it to the destination.
source§

fn size_hint(&self) -> usize

If possible give a hint of expected size of the encoding. Read more
source§

fn encode(&self) -> Vec<u8, Global>

Convert self to an owned vector.
source§

fn using_encoded<R, F>(&self, f: F) -> Rwhere F: FnOnce(&[u8]) -> R,

Convert self to a slice and then invoke the given closure with it.
source§

fn encoded_size(&self) -> usize

Calculates the encoded size. Read more
source§

impl<P> Encode for FixedPoint<i32, P>

Available on crate features parity and i32 only.
source§

fn encode_to<O: Output + ?Sized>(&self, destination: &mut O)

Convert self to a slice and append it to the destination.
source§

fn size_hint(&self) -> usize

If possible give a hint of expected size of the encoding. Read more
source§

fn encode(&self) -> Vec<u8, Global>

Convert self to an owned vector.
source§

fn using_encoded<R, F>(&self, f: F) -> Rwhere F: FnOnce(&[u8]) -> R,

Convert self to a slice and then invoke the given closure with it.
source§

fn encoded_size(&self) -> usize

Calculates the encoded size. Read more
source§

impl<P> Encode for FixedPoint<i64, P>

Available on crate features parity and i64 only.
source§

fn encode_to<O: Output + ?Sized>(&self, destination: &mut O)

Convert self to a slice and append it to the destination.
source§

fn size_hint(&self) -> usize

If possible give a hint of expected size of the encoding. Read more
source§

fn encode(&self) -> Vec<u8, Global>

Convert self to an owned vector.
source§

fn using_encoded<R, F>(&self, f: F) -> Rwhere F: FnOnce(&[u8]) -> R,

Convert self to a slice and then invoke the given closure with it.
source§

fn encoded_size(&self) -> usize

Calculates the encoded size. Read more
source§

impl<I, P> From<Compact<FixedPoint<I, P>>> for FixedPoint<I, P>

Available on crate feature parity only.
source§

fn from(value: Compact<Self>) -> Self

Converts to this type from the input type.
source§

impl<P: Precision> From<FixedPoint<i128, P>> for f64

source§

fn from(value: FixedPoint<i128, P>) -> Self

Converts to this type from the input type.
source§

impl<P: Precision> From<FixedPoint<i16, P>> for f64

source§

fn from(value: FixedPoint<i16, P>) -> Self

Converts to this type from the input type.
source§

impl<P: Precision> From<FixedPoint<i32, P>> for f64

source§

fn from(value: FixedPoint<i32, P>) -> Self

Converts to this type from the input type.
source§

impl<P: Precision> From<FixedPoint<i64, P>> for f64

source§

fn from(value: FixedPoint<i64, P>) -> Self

Converts to this type from the input type.
source§

impl<P: Precision> FromStr for FixedPoint<i128, P>

source§

fn from_str(str: &str) -> Result<Self, Self::Err>

Parses a string slice into a fixed point. If the value cannot be represented, it will be rounded to the nearest value.

Use from_str_exact to parse without rounding.

§

type Err = ConvertError

The associated error which can be returned from parsing.
source§

impl<P: Precision> FromStr for FixedPoint<i16, P>

source§

fn from_str(str: &str) -> Result<Self, Self::Err>

Parses a string slice into a fixed point. If the value cannot be represented, it will be rounded to the nearest value.

Use from_str_exact to parse without rounding.

§

type Err = ConvertError

The associated error which can be returned from parsing.
source§

impl<P: Precision> FromStr for FixedPoint<i32, P>

source§

fn from_str(str: &str) -> Result<Self, Self::Err>

Parses a string slice into a fixed point. If the value cannot be represented, it will be rounded to the nearest value.

Use from_str_exact to parse without rounding.

§

type Err = ConvertError

The associated error which can be returned from parsing.
source§

impl<P: Precision> FromStr for FixedPoint<i64, P>

source§

fn from_str(str: &str) -> Result<Self, Self::Err>

Parses a string slice into a fixed point. If the value cannot be represented, it will be rounded to the nearest value.

Use from_str_exact to parse without rounding.

§

type Err = ConvertError

The associated error which can be returned from parsing.
source§

impl<I: Hash, P: Hash> Hash for FixedPoint<I, P>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<I, P> JsonSchema for FixedPoint<I, P>

Available on crate feature schemars only.
source§

fn is_referenceable() -> bool

Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword. Read more
source§

fn schema_name() -> String

The name of the generated JSON Schema. Read more
source§

fn json_schema(_: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
source§

impl<P: Precision> One for FixedPoint<i128, P>

Available on crate feature i128 only.
source§

const ONE: Self = _

Represents 1.
source§

impl<P: Precision> One for FixedPoint<i16, P>

Available on crate feature i16 only.
source§

const ONE: Self = _

Represents 1.
source§

impl<P: Precision> One for FixedPoint<i32, P>

Available on crate feature i32 only.
source§

const ONE: Self = _

Represents 1.
source§

impl<P: Precision> One for FixedPoint<i64, P>

Available on crate feature i64 only.
source§

const ONE: Self = _

Represents 1.
source§

impl<I: Ord, P: Ord> Ord for FixedPoint<I, P>

source§

fn cmp(&self, other: &FixedPoint<I, P>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl<I: PartialEq, P: PartialEq> PartialEq<FixedPoint<I, P>> for FixedPoint<I, P>

source§

fn eq(&self, other: &FixedPoint<I, P>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<I: PartialOrd, P: PartialOrd> PartialOrd<FixedPoint<I, P>> for FixedPoint<I, P>

source§

fn partial_cmp(&self, other: &FixedPoint<I, P>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<P: Precision> RoundingDiv<FixedPoint<i128, P>> for FixedPoint<i128, P>

Available on crate feature i128 only.
§

type Output = FixedPoint<i128, P>

Result of division.
§

type Error = ArithmeticError

source§

fn rdiv(self, rhs: Self, mode: RoundMode) -> Result<Self, ArithmeticError>

Checked rounded division. Returns Err on overflow or attempt to divide by zero. Because of provided RoundMode it’s possible to perform across the FixedPoint values. Read more
source§

impl<P: Precision> RoundingDiv<FixedPoint<i128, P>> for i128

Available on crate feature i128 only.
§

type Output = FixedPoint<i128, P>

Result of division.
§

type Error = ArithmeticError

source§

fn rdiv( self, rhs: FixedPoint<i128, P>, mode: RoundMode ) -> Result<FixedPoint<i128, P>, ArithmeticError>

Checked rounded division. Returns Err on overflow or attempt to divide by zero. Because of provided RoundMode it’s possible to perform across the FixedPoint values. Read more
source§

impl<P: Precision> RoundingDiv<FixedPoint<i16, P>> for FixedPoint<i16, P>

Available on crate feature i16 only.
§

type Output = FixedPoint<i16, P>

Result of division.
§

type Error = ArithmeticError

source§

fn rdiv(self, rhs: Self, mode: RoundMode) -> Result<Self, ArithmeticError>

Checked rounded division. Returns Err on overflow or attempt to divide by zero. Because of provided RoundMode it’s possible to perform across the FixedPoint values. Read more
source§

impl<P: Precision> RoundingDiv<FixedPoint<i16, P>> for i16

Available on crate feature i16 only.
§

type Output = FixedPoint<i16, P>

Result of division.
§

type Error = ArithmeticError

source§

fn rdiv( self, rhs: FixedPoint<i16, P>, mode: RoundMode ) -> Result<FixedPoint<i16, P>, ArithmeticError>

Checked rounded division. Returns Err on overflow or attempt to divide by zero. Because of provided RoundMode it’s possible to perform across the FixedPoint values. Read more
source§

impl<P: Precision> RoundingDiv<FixedPoint<i32, P>> for FixedPoint<i32, P>

Available on crate feature i32 only.
§

type Output = FixedPoint<i32, P>

Result of division.
§

type Error = ArithmeticError

source§

fn rdiv(self, rhs: Self, mode: RoundMode) -> Result<Self, ArithmeticError>

Checked rounded division. Returns Err on overflow or attempt to divide by zero. Because of provided RoundMode it’s possible to perform across the FixedPoint values. Read more
source§

impl<P: Precision> RoundingDiv<FixedPoint<i32, P>> for i32

Available on crate feature i32 only.
§

type Output = FixedPoint<i32, P>

Result of division.
§

type Error = ArithmeticError

source§

fn rdiv( self, rhs: FixedPoint<i32, P>, mode: RoundMode ) -> Result<FixedPoint<i32, P>, ArithmeticError>

Checked rounded division. Returns Err on overflow or attempt to divide by zero. Because of provided RoundMode it’s possible to perform across the FixedPoint values. Read more
source§

impl<P: Precision> RoundingDiv<FixedPoint<i64, P>> for FixedPoint<i64, P>

Available on crate feature i64 only.
§

type Output = FixedPoint<i64, P>

Result of division.
§

type Error = ArithmeticError

source§

fn rdiv(self, rhs: Self, mode: RoundMode) -> Result<Self, ArithmeticError>

Checked rounded division. Returns Err on overflow or attempt to divide by zero. Because of provided RoundMode it’s possible to perform across the FixedPoint values. Read more
source§

impl<P: Precision> RoundingDiv<FixedPoint<i64, P>> for i64

Available on crate feature i64 only.
§

type Output = FixedPoint<i64, P>

Result of division.
§

type Error = ArithmeticError

source§

fn rdiv( self, rhs: FixedPoint<i64, P>, mode: RoundMode ) -> Result<FixedPoint<i64, P>, ArithmeticError>

Checked rounded division. Returns Err on overflow or attempt to divide by zero. Because of provided RoundMode it’s possible to perform across the FixedPoint values. Read more
source§

impl<P: Precision> RoundingDiv<i128> for FixedPoint<i128, P>

Available on crate feature i128 only.
§

type Output = FixedPoint<i128, P>

Result of division.
§

type Error = ArithmeticError

source§

fn rdiv(self, rhs: i128, mode: RoundMode) -> Result<Self, ArithmeticError>

Checked rounded division. Returns Err on overflow or attempt to divide by zero. Because of provided RoundMode it’s possible to perform across the FixedPoint values. Read more
source§

impl<P: Precision> RoundingDiv<i16> for FixedPoint<i16, P>

Available on crate feature i16 only.
§

type Output = FixedPoint<i16, P>

Result of division.
§

type Error = ArithmeticError

source§

fn rdiv(self, rhs: i16, mode: RoundMode) -> Result<Self, ArithmeticError>

Checked rounded division. Returns Err on overflow or attempt to divide by zero. Because of provided RoundMode it’s possible to perform across the FixedPoint values. Read more
source§

impl<P: Precision> RoundingDiv<i32> for FixedPoint<i32, P>

Available on crate feature i32 only.
§

type Output = FixedPoint<i32, P>

Result of division.
§

type Error = ArithmeticError

source§

fn rdiv(self, rhs: i32, mode: RoundMode) -> Result<Self, ArithmeticError>

Checked rounded division. Returns Err on overflow or attempt to divide by zero. Because of provided RoundMode it’s possible to perform across the FixedPoint values. Read more
source§

impl<P: Precision> RoundingDiv<i64> for FixedPoint<i64, P>

Available on crate feature i64 only.
§

type Output = FixedPoint<i64, P>

Result of division.
§

type Error = ArithmeticError

source§

fn rdiv(self, rhs: i64, mode: RoundMode) -> Result<Self, ArithmeticError>

Checked rounded division. Returns Err on overflow or attempt to divide by zero. Because of provided RoundMode it’s possible to perform across the FixedPoint values. Read more
source§

impl<P: Precision> RoundingMul<FixedPoint<i128, P>> for FixedPoint<i128, P>

Available on crate feature i128 only.
§

type Output = FixedPoint<i128, P>

Result of multiplication.
§

type Error = ArithmeticError

source§

fn rmul(self, rhs: Self, mode: RoundMode) -> Result<Self, ArithmeticError>

Checked rounded multiplication. Returns Err on overflow. Because of provided RoundMode it’s possible to perform across the FixedPoint values. Read more
source§

impl<P: Precision> RoundingMul<FixedPoint<i16, P>> for FixedPoint<i16, P>

Available on crate feature i16 only.
§

type Output = FixedPoint<i16, P>

Result of multiplication.
§

type Error = ArithmeticError

source§

fn rmul(self, rhs: Self, mode: RoundMode) -> Result<Self, ArithmeticError>

Checked rounded multiplication. Returns Err on overflow. Because of provided RoundMode it’s possible to perform across the FixedPoint values. Read more
source§

impl<P: Precision> RoundingMul<FixedPoint<i32, P>> for FixedPoint<i32, P>

Available on crate feature i32 only.
§

type Output = FixedPoint<i32, P>

Result of multiplication.
§

type Error = ArithmeticError

source§

fn rmul(self, rhs: Self, mode: RoundMode) -> Result<Self, ArithmeticError>

Checked rounded multiplication. Returns Err on overflow. Because of provided RoundMode it’s possible to perform across the FixedPoint values. Read more
source§

impl<P: Precision> RoundingMul<FixedPoint<i64, P>> for FixedPoint<i64, P>

Available on crate feature i64 only.
§

type Output = FixedPoint<i64, P>

Result of multiplication.
§

type Error = ArithmeticError

source§

fn rmul(self, rhs: Self, mode: RoundMode) -> Result<Self, ArithmeticError>

Checked rounded multiplication. Returns Err on overflow. Because of provided RoundMode it’s possible to perform across the FixedPoint values. Read more
source§

impl<I, P> Serialize for FixedPoint<I, P>where I: Serialize, Self: Stringify + Clone,

Available on crate feature serde only.
source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<P: Precision> TryFrom<f64> for FixedPoint<i128, P>

source§

fn try_from(value: f64) -> Result<Self, Self::Error>

Implementation courtesy of rust_decimal crate

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

impl<P: Precision> TryFrom<f64> for FixedPoint<i16, P>

source§

fn try_from(value: f64) -> Result<Self, Self::Error>

Implementation courtesy of rust_decimal crate

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

impl<P: Precision> TryFrom<f64> for FixedPoint<i32, P>

source§

fn try_from(value: f64) -> Result<Self, Self::Error>

Implementation courtesy of rust_decimal crate

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

impl<P: Precision> TryFrom<f64> for FixedPoint<i64, P>

source§

fn try_from(value: f64) -> Result<Self, Self::Error>

Implementation courtesy of rust_decimal crate

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

impl<P: Precision> TryFrom<i128> for FixedPoint<i128, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: i128) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<i128> for FixedPoint<i16, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: i128) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<i128> for FixedPoint<i32, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: i128) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<i128> for FixedPoint<i64, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: i128) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<i16> for FixedPoint<i128, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: i16) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<i16> for FixedPoint<i16, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: i16) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<i16> for FixedPoint<i32, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: i16) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<i16> for FixedPoint<i64, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: i16) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<i32> for FixedPoint<i128, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: i32) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<i32> for FixedPoint<i16, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: i32) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<i32> for FixedPoint<i32, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: i32) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<i32> for FixedPoint<i64, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: i32) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<i64> for FixedPoint<i128, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: i64) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<i64> for FixedPoint<i16, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: i64) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<i64> for FixedPoint<i32, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: i64) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<i64> for FixedPoint<i64, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: i64) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<i8> for FixedPoint<i128, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: i8) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<i8> for FixedPoint<i16, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: i8) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<i8> for FixedPoint<i32, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: i8) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<i8> for FixedPoint<i64, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: i8) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<isize> for FixedPoint<i128, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: isize) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<isize> for FixedPoint<i16, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: isize) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<isize> for FixedPoint<i32, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: isize) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<isize> for FixedPoint<i64, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: isize) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<u128> for FixedPoint<i128, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: u128) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<u128> for FixedPoint<i16, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: u128) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<u128> for FixedPoint<i32, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: u128) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<u128> for FixedPoint<i64, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: u128) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<u16> for FixedPoint<i128, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: u16) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<u16> for FixedPoint<i16, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: u16) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<u16> for FixedPoint<i32, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: u16) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<u16> for FixedPoint<i64, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: u16) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<u32> for FixedPoint<i128, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: u32) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<u32> for FixedPoint<i16, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: u32) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<u32> for FixedPoint<i32, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: u32) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<u32> for FixedPoint<i64, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: u32) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<u64> for FixedPoint<i128, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: u64) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<u64> for FixedPoint<i16, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: u64) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<u64> for FixedPoint<i32, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: u64) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<u64> for FixedPoint<i64, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: u64) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<u8> for FixedPoint<i128, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: u8) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<u8> for FixedPoint<i16, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: u8) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<u8> for FixedPoint<i32, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: u8) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<u8> for FixedPoint<i64, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: u8) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<usize> for FixedPoint<i128, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: usize) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<usize> for FixedPoint<i16, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: usize) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<usize> for FixedPoint<i32, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: usize) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> TryFrom<usize> for FixedPoint<i64, P>

§

type Error = ConvertError

The type returned in the event of a conversion error.
source§

fn try_from(value: usize) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<P: Precision> Zero for FixedPoint<i128, P>

Available on crate feature i128 only.
source§

const ZERO: Self = _

Represents 0.
source§

impl<P: Precision> Zero for FixedPoint<i16, P>

Available on crate feature i16 only.
source§

const ZERO: Self = _

Represents 0.
source§

impl<P: Precision> Zero for FixedPoint<i32, P>

Available on crate feature i32 only.
source§

const ZERO: Self = _

Represents 0.
source§

impl<P: Precision> Zero for FixedPoint<i64, P>

Available on crate feature i64 only.
source§

const ZERO: Self = _

Represents 0.
source§

impl<I: Copy, P: Copy> Copy for FixedPoint<I, P>

source§

impl<P> EncodeLike<FixedPoint<i128, P>> for FixedPoint<i128, P>

Available on crate features parity and i128 only.
source§

impl<P> EncodeLike<FixedPoint<i16, P>> for FixedPoint<i16, P>

Available on crate features parity and i16 only.
source§

impl<P> EncodeLike<FixedPoint<i32, P>> for FixedPoint<i32, P>

Available on crate features parity and i32 only.
source§

impl<P> EncodeLike<FixedPoint<i64, P>> for FixedPoint<i64, P>

Available on crate features parity and i64 only.
source§

impl<I: Eq, P: Eq> Eq for FixedPoint<I, P>

source§

impl<I, P> StructuralEq for FixedPoint<I, P>

source§

impl<I, P> StructuralPartialEq for FixedPoint<I, P>

Auto Trait Implementations§

§

impl<I, P> RefUnwindSafe for FixedPoint<I, P>where I: RefUnwindSafe, P: RefUnwindSafe,

§

impl<I, P> Send for FixedPoint<I, P>where I: Send, P: Send,

§

impl<I, P> Sync for FixedPoint<I, P>where I: Sync, P: Sync,

§

impl<I, P> Unpin for FixedPoint<I, P>where I: Unpin, P: Unpin,

§

impl<I, P> UnwindSafe for FixedPoint<I, P>where I: UnwindSafe, P: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> DecodeAll for Twhere T: Decode,

source§

fn decode_all(input: &mut &[u8]) -> Result<T, Error>

Decode Self and consume all of the given input data. Read more
source§

impl<T> DecodeLimit for Twhere T: Decode,

source§

fn decode_all_with_depth_limit(limit: u32, input: &mut &[u8]) -> Result<T, Error>

Decode Self and consume all of the given input data. Read more
source§

fn decode_with_depth_limit<I>(limit: u32, input: &mut I) -> Result<T, Error>where I: Input,

Decode Self with the given maximum recursion depth and advance input by the number of bytes consumed. Read more
source§

impl<T> DynClone for Twhere T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> HasCompact for Twhere T: 'static, Compact<T>: for<'a> EncodeAsRef<'a, T> + Decode + From<T> + Into<T>,

§

type Type = Compact<T>

The compact type; this can be
source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> KeyedVec for Twhere T: Codec,

source§

fn to_keyed_vec(&self, prepend_key: &[u8]) -> Vec<u8, Global>

Return an encoding of Self prepended by given slice.
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<S> Codec for Swhere S: Decode + Encode,

source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,

source§

impl<T> EncodeLike<&&T> for Twhere T: Encode,

source§

impl<T> EncodeLike<&T> for Twhere T: Encode,

source§

impl<T> EncodeLike<&mut T> for Twhere T: Encode,

source§

impl<T> EncodeLike<Box<T, Global>> for Twhere T: Encode,

source§

impl<'a, T> EncodeLike<Cow<'a, T>> for Twhere T: ToOwned + Encode,

source§

impl<S> FullCodec for Swhere S: Decode + FullEncode,

source§

impl<S> FullEncode for Swhere S: Encode + EncodeLike<S>,