Struct fixnum::FixedPoint
source · #[repr(transparent)]pub struct FixedPoint<I, P> { /* private fields */ }
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>
impl<P: Precision> FixedPoint<i16, P>
sourcepub fn from_str_exact(str: &str) -> Result<Self, ConvertError>
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>
impl<P: Precision> FixedPoint<i32, P>
sourcepub fn from_str_exact(str: &str) -> Result<Self, ConvertError>
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>
impl<P: Precision> FixedPoint<i64, P>
sourcepub fn from_str_exact(str: &str) -> Result<Self, ConvertError>
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>
impl<P: Precision> FixedPoint<i128, P>
sourcepub fn from_str_exact(str: &str) -> Result<Self, ConvertError>
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>
impl<I, P> FixedPoint<I, P>
source§impl<P: Precision> FixedPoint<i16, P>
impl<P: Precision> FixedPoint<i16, P>
source§impl<P: Precision> FixedPoint<i16, P>
impl<P: Precision> FixedPoint<i16, P>
sourcepub fn signum(self) -> i16
Available on crate feature i16
only.
pub fn signum(self) -> i16
i16
only.Returns a number representing sign of self.
0
if the number is zero1
if the number is positive-1
if the number is negative
sourcepub fn recip(self, mode: RoundMode) -> Result<Self, ArithmeticError>
Available on crate feature i16
only.
pub fn recip(self, mode: RoundMode) -> Result<Self, ArithmeticError>
i16
only.Returns 1/n
.
sourcepub fn cneg(self) -> Result<Self, ArithmeticError>
Available on crate feature i16
only.
pub fn cneg(self) -> Result<Self, ArithmeticError>
i16
only.Checked negation. Returns Err
on overflow (you can’t negate MIN
value).
sourcepub fn half_sum(a: Self, b: Self, mode: RoundMode) -> Self
Available on crate feature i16
only.
pub fn half_sum(a: Self, b: Self, mode: RoundMode) -> Self
i16
only.Calculates (a + b) / 2
.
sourcepub fn integral(self, mode: RoundMode) -> i16
Available on crate feature i16
only.
pub fn integral(self, mode: RoundMode) -> i16
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);
sourcepub fn floor(self) -> Self
Available on crate feature i16
only.
pub fn floor(self) -> Self
i16
only.Returns the largest integer less than or equal to a number.
sourcepub fn ceil(self) -> Self
Available on crate feature i16
only.
pub fn ceil(self) -> Self
i16
only.Returns the smallest integer greater than or equal to a number.
sourcepub fn round(self) -> Self
Available on crate feature i16
only.
pub fn round(self) -> Self
i16
only.Returns the nearest integer to a number. Round half-way cases away from 0.0
.
sourcepub fn round_towards_zero_by(self, precision: Self) -> Self
Available on crate feature i16
only.
pub fn round_towards_zero_by(self, precision: Self) -> Self
i16
only.Rounds towards zero by the provided precision.
sourcepub fn next_power_of_ten(self) -> Result<Self, ArithmeticError>
Available on crate feature i16
only.
pub fn next_power_of_ten(self) -> Result<Self, ArithmeticError>
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.
sourcepub fn abs(self) -> Result<Self, ArithmeticError>
Available on crate feature i16
only.
pub fn abs(self) -> Result<Self, ArithmeticError>
i16
only.Returns the absolute value of a number.
sourcepub fn rsqrt(self, mode: RoundMode) -> Result<Self, ArithmeticError>
Available on crate feature i16
only.
pub fn rsqrt(self, mode: RoundMode) -> Result<Self, ArithmeticError>
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
orCeil
, which one is closer tosqrt(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>
impl<P: Precision> FixedPoint<i16, P>
sourcepub fn from_decimal(mantissa: i16, exponent: i32) -> Result<Self, ConvertError>
Available on crate feature i16
only.
pub fn from_decimal(mantissa: i16, exponent: i32) -> Result<Self, ConvertError>
i16
only.Creates a new number from separate mantissa and exponent.
sourcepub fn to_decimal(&self, max_exponent: i32) -> (i16, i32)
Available on crate feature i16
only.
pub fn to_decimal(&self, max_exponent: i32) -> (i16, i32)
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>
impl<P: Precision> FixedPoint<i32, P>
source§impl<P: Precision> FixedPoint<i32, P>
impl<P: Precision> FixedPoint<i32, P>
sourcepub fn signum(self) -> i32
Available on crate feature i32
only.
pub fn signum(self) -> i32
i32
only.Returns a number representing sign of self.
0
if the number is zero1
if the number is positive-1
if the number is negative
sourcepub fn recip(self, mode: RoundMode) -> Result<Self, ArithmeticError>
Available on crate feature i32
only.
pub fn recip(self, mode: RoundMode) -> Result<Self, ArithmeticError>
i32
only.Returns 1/n
.
sourcepub fn cneg(self) -> Result<Self, ArithmeticError>
Available on crate feature i32
only.
pub fn cneg(self) -> Result<Self, ArithmeticError>
i32
only.Checked negation. Returns Err
on overflow (you can’t negate MIN
value).
sourcepub fn half_sum(a: Self, b: Self, mode: RoundMode) -> Self
Available on crate feature i32
only.
pub fn half_sum(a: Self, b: Self, mode: RoundMode) -> Self
i32
only.Calculates (a + b) / 2
.
sourcepub fn integral(self, mode: RoundMode) -> i32
Available on crate feature i32
only.
pub fn integral(self, mode: RoundMode) -> i32
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);
sourcepub fn floor(self) -> Self
Available on crate feature i32
only.
pub fn floor(self) -> Self
i32
only.Returns the largest integer less than or equal to a number.
sourcepub fn ceil(self) -> Self
Available on crate feature i32
only.
pub fn ceil(self) -> Self
i32
only.Returns the smallest integer greater than or equal to a number.
sourcepub fn round(self) -> Self
Available on crate feature i32
only.
pub fn round(self) -> Self
i32
only.Returns the nearest integer to a number. Round half-way cases away from 0.0
.
sourcepub fn round_towards_zero_by(self, precision: Self) -> Self
Available on crate feature i32
only.
pub fn round_towards_zero_by(self, precision: Self) -> Self
i32
only.Rounds towards zero by the provided precision.
sourcepub fn next_power_of_ten(self) -> Result<Self, ArithmeticError>
Available on crate feature i32
only.
pub fn next_power_of_ten(self) -> Result<Self, ArithmeticError>
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.
sourcepub fn abs(self) -> Result<Self, ArithmeticError>
Available on crate feature i32
only.
pub fn abs(self) -> Result<Self, ArithmeticError>
i32
only.Returns the absolute value of a number.
sourcepub fn rsqrt(self, mode: RoundMode) -> Result<Self, ArithmeticError>
Available on crate feature i32
only.
pub fn rsqrt(self, mode: RoundMode) -> Result<Self, ArithmeticError>
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
orCeil
, which one is closer tosqrt(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>
impl<P: Precision> FixedPoint<i32, P>
sourcepub fn from_decimal(mantissa: i32, exponent: i32) -> Result<Self, ConvertError>
Available on crate feature i32
only.
pub fn from_decimal(mantissa: i32, exponent: i32) -> Result<Self, ConvertError>
i32
only.Creates a new number from separate mantissa and exponent.
sourcepub fn to_decimal(&self, max_exponent: i32) -> (i32, i32)
Available on crate feature i32
only.
pub fn to_decimal(&self, max_exponent: i32) -> (i32, i32)
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>
impl<P: Precision> FixedPoint<i64, P>
source§impl<P: Precision> FixedPoint<i64, P>
impl<P: Precision> FixedPoint<i64, P>
sourcepub fn signum(self) -> i64
Available on crate feature i64
only.
pub fn signum(self) -> i64
i64
only.Returns a number representing sign of self.
0
if the number is zero1
if the number is positive-1
if the number is negative
sourcepub fn recip(self, mode: RoundMode) -> Result<Self, ArithmeticError>
Available on crate feature i64
only.
pub fn recip(self, mode: RoundMode) -> Result<Self, ArithmeticError>
i64
only.Returns 1/n
.
sourcepub fn cneg(self) -> Result<Self, ArithmeticError>
Available on crate feature i64
only.
pub fn cneg(self) -> Result<Self, ArithmeticError>
i64
only.Checked negation. Returns Err
on overflow (you can’t negate MIN
value).
sourcepub fn half_sum(a: Self, b: Self, mode: RoundMode) -> Self
Available on crate feature i64
only.
pub fn half_sum(a: Self, b: Self, mode: RoundMode) -> Self
i64
only.Calculates (a + b) / 2
.
sourcepub fn integral(self, mode: RoundMode) -> i64
Available on crate feature i64
only.
pub fn integral(self, mode: RoundMode) -> i64
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);
sourcepub fn floor(self) -> Self
Available on crate feature i64
only.
pub fn floor(self) -> Self
i64
only.Returns the largest integer less than or equal to a number.
sourcepub fn ceil(self) -> Self
Available on crate feature i64
only.
pub fn ceil(self) -> Self
i64
only.Returns the smallest integer greater than or equal to a number.
sourcepub fn round(self) -> Self
Available on crate feature i64
only.
pub fn round(self) -> Self
i64
only.Returns the nearest integer to a number. Round half-way cases away from 0.0
.
sourcepub fn round_towards_zero_by(self, precision: Self) -> Self
Available on crate feature i64
only.
pub fn round_towards_zero_by(self, precision: Self) -> Self
i64
only.Rounds towards zero by the provided precision.
sourcepub fn next_power_of_ten(self) -> Result<Self, ArithmeticError>
Available on crate feature i64
only.
pub fn next_power_of_ten(self) -> Result<Self, ArithmeticError>
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.
sourcepub fn abs(self) -> Result<Self, ArithmeticError>
Available on crate feature i64
only.
pub fn abs(self) -> Result<Self, ArithmeticError>
i64
only.Returns the absolute value of a number.
sourcepub fn rsqrt(self, mode: RoundMode) -> Result<Self, ArithmeticError>
Available on crate feature i64
only.
pub fn rsqrt(self, mode: RoundMode) -> Result<Self, ArithmeticError>
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
orCeil
, which one is closer tosqrt(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>
impl<P: Precision> FixedPoint<i64, P>
sourcepub fn from_decimal(mantissa: i64, exponent: i32) -> Result<Self, ConvertError>
Available on crate feature i64
only.
pub fn from_decimal(mantissa: i64, exponent: i32) -> Result<Self, ConvertError>
i64
only.Creates a new number from separate mantissa and exponent.
sourcepub fn to_decimal(&self, max_exponent: i32) -> (i64, i32)
Available on crate feature i64
only.
pub fn to_decimal(&self, max_exponent: i32) -> (i64, i32)
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>
impl<P: Precision> FixedPoint<i128, P>
source§impl<P: Precision> FixedPoint<i128, P>
impl<P: Precision> FixedPoint<i128, P>
sourcepub fn signum(self) -> i128
Available on crate feature i128
only.
pub fn signum(self) -> i128
i128
only.Returns a number representing sign of self.
0
if the number is zero1
if the number is positive-1
if the number is negative
sourcepub fn recip(self, mode: RoundMode) -> Result<Self, ArithmeticError>
Available on crate feature i128
only.
pub fn recip(self, mode: RoundMode) -> Result<Self, ArithmeticError>
i128
only.Returns 1/n
.
sourcepub fn cneg(self) -> Result<Self, ArithmeticError>
Available on crate feature i128
only.
pub fn cneg(self) -> Result<Self, ArithmeticError>
i128
only.Checked negation. Returns Err
on overflow (you can’t negate MIN
value).
sourcepub fn half_sum(a: Self, b: Self, mode: RoundMode) -> Self
Available on crate feature i128
only.
pub fn half_sum(a: Self, b: Self, mode: RoundMode) -> Self
i128
only.Calculates (a + b) / 2
.
sourcepub fn integral(self, mode: RoundMode) -> i128
Available on crate feature i128
only.
pub fn integral(self, mode: RoundMode) -> i128
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);
sourcepub fn floor(self) -> Self
Available on crate feature i128
only.
pub fn floor(self) -> Self
i128
only.Returns the largest integer less than or equal to a number.
sourcepub fn ceil(self) -> Self
Available on crate feature i128
only.
pub fn ceil(self) -> Self
i128
only.Returns the smallest integer greater than or equal to a number.
sourcepub fn round(self) -> Self
Available on crate feature i128
only.
pub fn round(self) -> Self
i128
only.Returns the nearest integer to a number. Round half-way cases away from 0.0
.
sourcepub fn round_towards_zero_by(self, precision: Self) -> Self
Available on crate feature i128
only.
pub fn round_towards_zero_by(self, precision: Self) -> Self
i128
only.Rounds towards zero by the provided precision.
sourcepub fn next_power_of_ten(self) -> Result<Self, ArithmeticError>
Available on crate feature i128
only.
pub fn next_power_of_ten(self) -> Result<Self, ArithmeticError>
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.
sourcepub fn abs(self) -> Result<Self, ArithmeticError>
Available on crate feature i128
only.
pub fn abs(self) -> Result<Self, ArithmeticError>
i128
only.Returns the absolute value of a number.
sourcepub fn rsqrt(self, mode: RoundMode) -> Result<Self, ArithmeticError>
Available on crate feature i128
only.
pub fn rsqrt(self, mode: RoundMode) -> Result<Self, ArithmeticError>
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
orCeil
, which one is closer tosqrt(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>
impl<P: Precision> FixedPoint<i128, P>
sourcepub fn from_decimal(mantissa: i128, exponent: i32) -> Result<Self, ConvertError>
Available on crate feature i128
only.
pub fn from_decimal(mantissa: i128, exponent: i32) -> Result<Self, ConvertError>
i128
only.Creates a new number from separate mantissa and exponent.
sourcepub fn to_decimal(&self, max_exponent: i32) -> (i128, i32)
Available on crate feature i128
only.
pub fn to_decimal(&self, max_exponent: i32) -> (i128, i32)
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> CheckedAdd<FixedPoint<i128, P>> for FixedPoint<i128, P>
Available on crate feature i128
only.
impl<P: Precision> CheckedAdd<FixedPoint<i128, P>> for FixedPoint<i128, P>
i128
only.§type Output = FixedPoint<i128, P>
type Output = FixedPoint<i128, P>
§type Error = ArithmeticError
type Error = ArithmeticError
ArithmeticError
.source§impl<P: Precision> CheckedAdd<FixedPoint<i16, P>> for FixedPoint<i16, P>
Available on crate feature i16
only.
impl<P: Precision> CheckedAdd<FixedPoint<i16, P>> for FixedPoint<i16, P>
i16
only.§type Output = FixedPoint<i16, P>
type Output = FixedPoint<i16, P>
§type Error = ArithmeticError
type Error = ArithmeticError
ArithmeticError
.source§impl<P: Precision> CheckedAdd<FixedPoint<i32, P>> for FixedPoint<i32, P>
Available on crate feature i32
only.
impl<P: Precision> CheckedAdd<FixedPoint<i32, P>> for FixedPoint<i32, P>
i32
only.§type Output = FixedPoint<i32, P>
type Output = FixedPoint<i32, P>
§type Error = ArithmeticError
type Error = ArithmeticError
ArithmeticError
.source§impl<P: Precision> CheckedAdd<FixedPoint<i64, P>> for FixedPoint<i64, P>
Available on crate feature i64
only.
impl<P: Precision> CheckedAdd<FixedPoint<i64, P>> for FixedPoint<i64, P>
i64
only.§type Output = FixedPoint<i64, P>
type Output = FixedPoint<i64, P>
§type Error = ArithmeticError
type Error = ArithmeticError
ArithmeticError
.source§impl<P: Precision> CheckedMul<FixedPoint<i128, P>> for i128
Available on crate feature i128
only.
impl<P: Precision> CheckedMul<FixedPoint<i128, P>> for i128
i128
only.§type Output = FixedPoint<i128, P>
type Output = FixedPoint<i128, P>
§type Error = ArithmeticError
type Error = ArithmeticError
ArithmeticError
.source§fn cmul(
self,
rhs: FixedPoint<i128, P>
) -> Result<FixedPoint<i128, P>, ArithmeticError>
fn cmul( self, rhs: FixedPoint<i128, P> ) -> Result<FixedPoint<i128, P>, ArithmeticError>
Err
on overflow.
This is multiplication without rounding, hence it’s available only when at least one operand is integer. Read moresource§fn saturating_mul(self, rhs: FixedPoint<i128, P>) -> Self::Output
fn saturating_mul(self, rhs: FixedPoint<i128, P>) -> Self::Output
source§impl<P: Precision> CheckedMul<FixedPoint<i16, P>> for i16
Available on crate feature i16
only.
impl<P: Precision> CheckedMul<FixedPoint<i16, P>> for i16
i16
only.§type Output = FixedPoint<i16, P>
type Output = FixedPoint<i16, P>
§type Error = ArithmeticError
type Error = ArithmeticError
ArithmeticError
.source§fn cmul(
self,
rhs: FixedPoint<i16, P>
) -> Result<FixedPoint<i16, P>, ArithmeticError>
fn cmul( self, rhs: FixedPoint<i16, P> ) -> Result<FixedPoint<i16, P>, ArithmeticError>
Err
on overflow.
This is multiplication without rounding, hence it’s available only when at least one operand is integer. Read moresource§fn saturating_mul(self, rhs: FixedPoint<i16, P>) -> Self::Output
fn saturating_mul(self, rhs: FixedPoint<i16, P>) -> Self::Output
source§impl<P: Precision> CheckedMul<FixedPoint<i32, P>> for i32
Available on crate feature i32
only.
impl<P: Precision> CheckedMul<FixedPoint<i32, P>> for i32
i32
only.§type Output = FixedPoint<i32, P>
type Output = FixedPoint<i32, P>
§type Error = ArithmeticError
type Error = ArithmeticError
ArithmeticError
.source§fn cmul(
self,
rhs: FixedPoint<i32, P>
) -> Result<FixedPoint<i32, P>, ArithmeticError>
fn cmul( self, rhs: FixedPoint<i32, P> ) -> Result<FixedPoint<i32, P>, ArithmeticError>
Err
on overflow.
This is multiplication without rounding, hence it’s available only when at least one operand is integer. Read moresource§fn saturating_mul(self, rhs: FixedPoint<i32, P>) -> Self::Output
fn saturating_mul(self, rhs: FixedPoint<i32, P>) -> Self::Output
source§impl<P: Precision> CheckedMul<FixedPoint<i64, P>> for i64
Available on crate feature i64
only.
impl<P: Precision> CheckedMul<FixedPoint<i64, P>> for i64
i64
only.§type Output = FixedPoint<i64, P>
type Output = FixedPoint<i64, P>
§type Error = ArithmeticError
type Error = ArithmeticError
ArithmeticError
.source§fn cmul(
self,
rhs: FixedPoint<i64, P>
) -> Result<FixedPoint<i64, P>, ArithmeticError>
fn cmul( self, rhs: FixedPoint<i64, P> ) -> Result<FixedPoint<i64, P>, ArithmeticError>
Err
on overflow.
This is multiplication without rounding, hence it’s available only when at least one operand is integer. Read moresource§fn saturating_mul(self, rhs: FixedPoint<i64, P>) -> Self::Output
fn saturating_mul(self, rhs: FixedPoint<i64, P>) -> Self::Output
source§impl<P: Precision> CheckedMul<i128> for FixedPoint<i128, P>
Available on crate feature i128
only.
impl<P: Precision> CheckedMul<i128> for FixedPoint<i128, P>
i128
only.§type Output = FixedPoint<i128, P>
type Output = FixedPoint<i128, P>
§type Error = ArithmeticError
type Error = ArithmeticError
ArithmeticError
.source§impl<P: Precision> CheckedMul<i16> for FixedPoint<i16, P>
Available on crate feature i16
only.
impl<P: Precision> CheckedMul<i16> for FixedPoint<i16, P>
i16
only.§type Output = FixedPoint<i16, P>
type Output = FixedPoint<i16, P>
§type Error = ArithmeticError
type Error = ArithmeticError
ArithmeticError
.source§impl<P: Precision> CheckedMul<i32> for FixedPoint<i32, P>
Available on crate feature i32
only.
impl<P: Precision> CheckedMul<i32> for FixedPoint<i32, P>
i32
only.§type Output = FixedPoint<i32, P>
type Output = FixedPoint<i32, P>
§type Error = ArithmeticError
type Error = ArithmeticError
ArithmeticError
.source§impl<P: Precision> CheckedMul<i64> for FixedPoint<i64, P>
Available on crate feature i64
only.
impl<P: Precision> CheckedMul<i64> for FixedPoint<i64, P>
i64
only.§type Output = FixedPoint<i64, P>
type Output = FixedPoint<i64, P>
§type Error = ArithmeticError
type Error = ArithmeticError
ArithmeticError
.source§impl<P: Precision> CheckedSub<FixedPoint<i128, P>> for FixedPoint<i128, P>
Available on crate feature i128
only.
impl<P: Precision> CheckedSub<FixedPoint<i128, P>> for FixedPoint<i128, P>
i128
only.§type Output = FixedPoint<i128, P>
type Output = FixedPoint<i128, P>
§type Error = ArithmeticError
type Error = ArithmeticError
ArithmeticError
.source§impl<P: Precision> CheckedSub<FixedPoint<i16, P>> for FixedPoint<i16, P>
Available on crate feature i16
only.
impl<P: Precision> CheckedSub<FixedPoint<i16, P>> for FixedPoint<i16, P>
i16
only.§type Output = FixedPoint<i16, P>
type Output = FixedPoint<i16, P>
§type Error = ArithmeticError
type Error = ArithmeticError
ArithmeticError
.source§impl<P: Precision> CheckedSub<FixedPoint<i32, P>> for FixedPoint<i32, P>
Available on crate feature i32
only.
impl<P: Precision> CheckedSub<FixedPoint<i32, P>> for FixedPoint<i32, P>
i32
only.§type Output = FixedPoint<i32, P>
type Output = FixedPoint<i32, P>
§type Error = ArithmeticError
type Error = ArithmeticError
ArithmeticError
.source§impl<P: Precision> CheckedSub<FixedPoint<i64, P>> for FixedPoint<i64, P>
Available on crate feature i64
only.
impl<P: Precision> CheckedSub<FixedPoint<i64, P>> for FixedPoint<i64, P>
i64
only.§type Output = FixedPoint<i64, P>
type Output = FixedPoint<i64, P>
§type Error = ArithmeticError
type Error = ArithmeticError
ArithmeticError
.source§impl<I: Clone, P: Clone> Clone for FixedPoint<I, P>
impl<I: Clone, P: Clone> Clone for FixedPoint<I, P>
source§fn clone(&self) -> FixedPoint<I, P>
fn clone(&self) -> FixedPoint<I, P>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<P> CompactAs for FixedPoint<i128, P>
Available on crate features parity
and i128
only.
impl<P> CompactAs for FixedPoint<i128, P>
parity
and i128
only.source§impl<P> CompactAs for FixedPoint<i16, P>
Available on crate features parity
and i16
only.
impl<P> CompactAs for FixedPoint<i16, P>
parity
and i16
only.source§impl<P> CompactAs for FixedPoint<i32, P>
Available on crate features parity
and i32
only.
impl<P> CompactAs for FixedPoint<i32, P>
parity
and i32
only.source§impl<P> CompactAs for FixedPoint<i64, P>
Available on crate features parity
and i64
only.
impl<P> CompactAs for FixedPoint<i64, P>
parity
and i64
only.source§impl<P> Decode for FixedPoint<i128, P>
Available on crate features parity
and i128
only.
impl<P> Decode for FixedPoint<i128, P>
parity
and i128
only.source§impl<P> Decode for FixedPoint<i16, P>
Available on crate features parity
and i16
only.
impl<P> Decode for FixedPoint<i16, P>
parity
and i16
only.source§impl<P> Decode for FixedPoint<i32, P>
Available on crate features parity
and i32
only.
impl<P> Decode for FixedPoint<i32, P>
parity
and i32
only.source§impl<P> Decode for FixedPoint<i64, P>
Available on crate features parity
and i64
only.
impl<P> Decode for FixedPoint<i64, P>
parity
and i64
only.source§impl<I: Default, P: Default> Default for FixedPoint<I, P>
impl<I: Default, P: Default> Default for FixedPoint<I, P>
source§fn default() -> FixedPoint<I, P>
fn default() -> FixedPoint<I, P>
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.
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>,
serde
only.source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where D: Deserializer<'de>,
source§impl<P> Encode for FixedPoint<i128, P>
Available on crate features parity
and i128
only.
impl<P> Encode for FixedPoint<i128, P>
parity
and i128
only.source§fn encode_to<O: Output + ?Sized>(&self, destination: &mut O)
fn encode_to<O: Output + ?Sized>(&self, destination: &mut O)
source§fn size_hint(&self) -> usize
fn size_hint(&self) -> usize
source§fn using_encoded<R, F>(&self, f: F) -> Rwhere
F: FnOnce(&[u8]) -> R,
fn using_encoded<R, F>(&self, f: F) -> Rwhere F: FnOnce(&[u8]) -> R,
source§fn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
source§impl<P> Encode for FixedPoint<i16, P>
Available on crate features parity
and i16
only.
impl<P> Encode for FixedPoint<i16, P>
parity
and i16
only.source§fn encode_to<O: Output + ?Sized>(&self, destination: &mut O)
fn encode_to<O: Output + ?Sized>(&self, destination: &mut O)
source§fn size_hint(&self) -> usize
fn size_hint(&self) -> usize
source§fn using_encoded<R, F>(&self, f: F) -> Rwhere
F: FnOnce(&[u8]) -> R,
fn using_encoded<R, F>(&self, f: F) -> Rwhere F: FnOnce(&[u8]) -> R,
source§fn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
source§impl<P> Encode for FixedPoint<i32, P>
Available on crate features parity
and i32
only.
impl<P> Encode for FixedPoint<i32, P>
parity
and i32
only.source§fn encode_to<O: Output + ?Sized>(&self, destination: &mut O)
fn encode_to<O: Output + ?Sized>(&self, destination: &mut O)
source§fn size_hint(&self) -> usize
fn size_hint(&self) -> usize
source§fn using_encoded<R, F>(&self, f: F) -> Rwhere
F: FnOnce(&[u8]) -> R,
fn using_encoded<R, F>(&self, f: F) -> Rwhere F: FnOnce(&[u8]) -> R,
source§fn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
source§impl<P> Encode for FixedPoint<i64, P>
Available on crate features parity
and i64
only.
impl<P> Encode for FixedPoint<i64, P>
parity
and i64
only.source§fn encode_to<O: Output + ?Sized>(&self, destination: &mut O)
fn encode_to<O: Output + ?Sized>(&self, destination: &mut O)
source§fn size_hint(&self) -> usize
fn size_hint(&self) -> usize
source§fn using_encoded<R, F>(&self, f: F) -> Rwhere
F: FnOnce(&[u8]) -> R,
fn using_encoded<R, F>(&self, f: F) -> Rwhere F: FnOnce(&[u8]) -> R,
source§fn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
source§impl<I, P> From<Compact<FixedPoint<I, P>>> for FixedPoint<I, P>
Available on crate feature parity
only.
impl<I, P> From<Compact<FixedPoint<I, P>>> for FixedPoint<I, P>
parity
only.source§impl<P: Precision> From<FixedPoint<i128, P>> for f64
impl<P: Precision> From<FixedPoint<i128, P>> for f64
source§fn from(value: FixedPoint<i128, P>) -> Self
fn from(value: FixedPoint<i128, P>) -> Self
source§impl<P: Precision> From<FixedPoint<i16, P>> for f64
impl<P: Precision> From<FixedPoint<i16, P>> for f64
source§fn from(value: FixedPoint<i16, P>) -> Self
fn from(value: FixedPoint<i16, P>) -> Self
source§impl<P: Precision> From<FixedPoint<i32, P>> for f64
impl<P: Precision> From<FixedPoint<i32, P>> for f64
source§fn from(value: FixedPoint<i32, P>) -> Self
fn from(value: FixedPoint<i32, P>) -> Self
source§impl<P: Precision> From<FixedPoint<i64, P>> for f64
impl<P: Precision> From<FixedPoint<i64, P>> for f64
source§fn from(value: FixedPoint<i64, P>) -> Self
fn from(value: FixedPoint<i64, P>) -> Self
source§impl<P: Precision> FromStr for FixedPoint<i128, P>
impl<P: Precision> FromStr for FixedPoint<i128, P>
source§fn from_str(str: &str) -> Result<Self, Self::Err>
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
type Err = ConvertError
source§impl<P: Precision> FromStr for FixedPoint<i16, P>
impl<P: Precision> FromStr for FixedPoint<i16, P>
source§fn from_str(str: &str) -> Result<Self, Self::Err>
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
type Err = ConvertError
source§impl<P: Precision> FromStr for FixedPoint<i32, P>
impl<P: Precision> FromStr for FixedPoint<i32, P>
source§fn from_str(str: &str) -> Result<Self, Self::Err>
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
type Err = ConvertError
source§impl<P: Precision> FromStr for FixedPoint<i64, P>
impl<P: Precision> FromStr for FixedPoint<i64, P>
source§fn from_str(str: &str) -> Result<Self, Self::Err>
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
type Err = ConvertError
source§impl<I, P> JsonSchema for FixedPoint<I, P>
Available on crate feature schemars
only.
impl<I, P> JsonSchema for FixedPoint<I, P>
schemars
only.source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref
keyword. Read moresource§fn schema_name() -> String
fn schema_name() -> String
source§fn json_schema(_: &mut SchemaGenerator) -> Schema
fn json_schema(_: &mut SchemaGenerator) -> Schema
source§impl<I: Ord, P: Ord> Ord for FixedPoint<I, P>
impl<I: Ord, P: Ord> Ord for FixedPoint<I, P>
source§fn cmp(&self, other: &FixedPoint<I, P>) -> Ordering
fn cmp(&self, other: &FixedPoint<I, P>) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
source§impl<I: PartialEq, P: PartialEq> PartialEq<FixedPoint<I, P>> for FixedPoint<I, P>
impl<I: PartialEq, P: PartialEq> PartialEq<FixedPoint<I, P>> for FixedPoint<I, P>
source§fn eq(&self, other: &FixedPoint<I, P>) -> bool
fn eq(&self, other: &FixedPoint<I, P>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<I: PartialOrd, P: PartialOrd> PartialOrd<FixedPoint<I, P>> for FixedPoint<I, P>
impl<I: PartialOrd, P: PartialOrd> PartialOrd<FixedPoint<I, P>> for FixedPoint<I, P>
source§fn partial_cmp(&self, other: &FixedPoint<I, P>) -> Option<Ordering>
fn partial_cmp(&self, other: &FixedPoint<I, P>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<P: Precision> RoundingDiv<FixedPoint<i128, P>> for FixedPoint<i128, P>
Available on crate feature i128
only.
impl<P: Precision> RoundingDiv<FixedPoint<i128, P>> for FixedPoint<i128, P>
i128
only.§type Output = FixedPoint<i128, P>
type Output = FixedPoint<i128, P>
§type Error = ArithmeticError
type Error = ArithmeticError
ArithmeticError
.source§fn rdiv(self, rhs: Self, mode: RoundMode) -> Result<Self, ArithmeticError>
fn rdiv(self, rhs: Self, mode: RoundMode) -> Result<Self, ArithmeticError>
Err
on overflow or attempt to divide by zero.
Because of provided RoundMode
it’s possible to perform across the FixedPoint
values. Read moresource§impl<P: Precision> RoundingDiv<FixedPoint<i128, P>> for i128
Available on crate feature i128
only.
impl<P: Precision> RoundingDiv<FixedPoint<i128, P>> for i128
i128
only.§type Output = FixedPoint<i128, P>
type Output = FixedPoint<i128, P>
§type Error = ArithmeticError
type Error = ArithmeticError
ArithmeticError
.source§fn rdiv(
self,
rhs: FixedPoint<i128, P>,
mode: RoundMode
) -> Result<FixedPoint<i128, P>, ArithmeticError>
fn rdiv( self, rhs: FixedPoint<i128, P>, mode: RoundMode ) -> Result<FixedPoint<i128, P>, ArithmeticError>
Err
on overflow or attempt to divide by zero.
Because of provided RoundMode
it’s possible to perform across the FixedPoint
values. Read moresource§impl<P: Precision> RoundingDiv<FixedPoint<i16, P>> for FixedPoint<i16, P>
Available on crate feature i16
only.
impl<P: Precision> RoundingDiv<FixedPoint<i16, P>> for FixedPoint<i16, P>
i16
only.§type Output = FixedPoint<i16, P>
type Output = FixedPoint<i16, P>
§type Error = ArithmeticError
type Error = ArithmeticError
ArithmeticError
.source§fn rdiv(self, rhs: Self, mode: RoundMode) -> Result<Self, ArithmeticError>
fn rdiv(self, rhs: Self, mode: RoundMode) -> Result<Self, ArithmeticError>
Err
on overflow or attempt to divide by zero.
Because of provided RoundMode
it’s possible to perform across the FixedPoint
values. Read moresource§impl<P: Precision> RoundingDiv<FixedPoint<i16, P>> for i16
Available on crate feature i16
only.
impl<P: Precision> RoundingDiv<FixedPoint<i16, P>> for i16
i16
only.§type Output = FixedPoint<i16, P>
type Output = FixedPoint<i16, P>
§type Error = ArithmeticError
type Error = ArithmeticError
ArithmeticError
.source§fn rdiv(
self,
rhs: FixedPoint<i16, P>,
mode: RoundMode
) -> Result<FixedPoint<i16, P>, ArithmeticError>
fn rdiv( self, rhs: FixedPoint<i16, P>, mode: RoundMode ) -> Result<FixedPoint<i16, P>, ArithmeticError>
Err
on overflow or attempt to divide by zero.
Because of provided RoundMode
it’s possible to perform across the FixedPoint
values. Read moresource§impl<P: Precision> RoundingDiv<FixedPoint<i32, P>> for FixedPoint<i32, P>
Available on crate feature i32
only.
impl<P: Precision> RoundingDiv<FixedPoint<i32, P>> for FixedPoint<i32, P>
i32
only.§type Output = FixedPoint<i32, P>
type Output = FixedPoint<i32, P>
§type Error = ArithmeticError
type Error = ArithmeticError
ArithmeticError
.source§fn rdiv(self, rhs: Self, mode: RoundMode) -> Result<Self, ArithmeticError>
fn rdiv(self, rhs: Self, mode: RoundMode) -> Result<Self, ArithmeticError>
Err
on overflow or attempt to divide by zero.
Because of provided RoundMode
it’s possible to perform across the FixedPoint
values. Read moresource§impl<P: Precision> RoundingDiv<FixedPoint<i32, P>> for i32
Available on crate feature i32
only.
impl<P: Precision> RoundingDiv<FixedPoint<i32, P>> for i32
i32
only.§type Output = FixedPoint<i32, P>
type Output = FixedPoint<i32, P>
§type Error = ArithmeticError
type Error = ArithmeticError
ArithmeticError
.source§fn rdiv(
self,
rhs: FixedPoint<i32, P>,
mode: RoundMode
) -> Result<FixedPoint<i32, P>, ArithmeticError>
fn rdiv( self, rhs: FixedPoint<i32, P>, mode: RoundMode ) -> Result<FixedPoint<i32, P>, ArithmeticError>
Err
on overflow or attempt to divide by zero.
Because of provided RoundMode
it’s possible to perform across the FixedPoint
values. Read moresource§impl<P: Precision> RoundingDiv<FixedPoint<i64, P>> for FixedPoint<i64, P>
Available on crate feature i64
only.
impl<P: Precision> RoundingDiv<FixedPoint<i64, P>> for FixedPoint<i64, P>
i64
only.§type Output = FixedPoint<i64, P>
type Output = FixedPoint<i64, P>
§type Error = ArithmeticError
type Error = ArithmeticError
ArithmeticError
.source§fn rdiv(self, rhs: Self, mode: RoundMode) -> Result<Self, ArithmeticError>
fn rdiv(self, rhs: Self, mode: RoundMode) -> Result<Self, ArithmeticError>
Err
on overflow or attempt to divide by zero.
Because of provided RoundMode
it’s possible to perform across the FixedPoint
values. Read moresource§impl<P: Precision> RoundingDiv<FixedPoint<i64, P>> for i64
Available on crate feature i64
only.
impl<P: Precision> RoundingDiv<FixedPoint<i64, P>> for i64
i64
only.§type Output = FixedPoint<i64, P>
type Output = FixedPoint<i64, P>
§type Error = ArithmeticError
type Error = ArithmeticError
ArithmeticError
.source§fn rdiv(
self,
rhs: FixedPoint<i64, P>,
mode: RoundMode
) -> Result<FixedPoint<i64, P>, ArithmeticError>
fn rdiv( self, rhs: FixedPoint<i64, P>, mode: RoundMode ) -> Result<FixedPoint<i64, P>, ArithmeticError>
Err
on overflow or attempt to divide by zero.
Because of provided RoundMode
it’s possible to perform across the FixedPoint
values. Read moresource§impl<P: Precision> RoundingDiv<i128> for FixedPoint<i128, P>
Available on crate feature i128
only.
impl<P: Precision> RoundingDiv<i128> for FixedPoint<i128, P>
i128
only.§type Output = FixedPoint<i128, P>
type Output = FixedPoint<i128, P>
§type Error = ArithmeticError
type Error = ArithmeticError
ArithmeticError
.source§fn rdiv(self, rhs: i128, mode: RoundMode) -> Result<Self, ArithmeticError>
fn rdiv(self, rhs: i128, mode: RoundMode) -> Result<Self, ArithmeticError>
Err
on overflow or attempt to divide by zero.
Because of provided RoundMode
it’s possible to perform across the FixedPoint
values. Read moresource§impl<P: Precision> RoundingDiv<i16> for FixedPoint<i16, P>
Available on crate feature i16
only.
impl<P: Precision> RoundingDiv<i16> for FixedPoint<i16, P>
i16
only.§type Output = FixedPoint<i16, P>
type Output = FixedPoint<i16, P>
§type Error = ArithmeticError
type Error = ArithmeticError
ArithmeticError
.source§fn rdiv(self, rhs: i16, mode: RoundMode) -> Result<Self, ArithmeticError>
fn rdiv(self, rhs: i16, mode: RoundMode) -> Result<Self, ArithmeticError>
Err
on overflow or attempt to divide by zero.
Because of provided RoundMode
it’s possible to perform across the FixedPoint
values. Read moresource§impl<P: Precision> RoundingDiv<i32> for FixedPoint<i32, P>
Available on crate feature i32
only.
impl<P: Precision> RoundingDiv<i32> for FixedPoint<i32, P>
i32
only.§type Output = FixedPoint<i32, P>
type Output = FixedPoint<i32, P>
§type Error = ArithmeticError
type Error = ArithmeticError
ArithmeticError
.source§fn rdiv(self, rhs: i32, mode: RoundMode) -> Result<Self, ArithmeticError>
fn rdiv(self, rhs: i32, mode: RoundMode) -> Result<Self, ArithmeticError>
Err
on overflow or attempt to divide by zero.
Because of provided RoundMode
it’s possible to perform across the FixedPoint
values. Read moresource§impl<P: Precision> RoundingDiv<i64> for FixedPoint<i64, P>
Available on crate feature i64
only.
impl<P: Precision> RoundingDiv<i64> for FixedPoint<i64, P>
i64
only.§type Output = FixedPoint<i64, P>
type Output = FixedPoint<i64, P>
§type Error = ArithmeticError
type Error = ArithmeticError
ArithmeticError
.source§fn rdiv(self, rhs: i64, mode: RoundMode) -> Result<Self, ArithmeticError>
fn rdiv(self, rhs: i64, mode: RoundMode) -> Result<Self, ArithmeticError>
Err
on overflow or attempt to divide by zero.
Because of provided RoundMode
it’s possible to perform across the FixedPoint
values. Read moresource§impl<P: Precision> RoundingMul<FixedPoint<i128, P>> for FixedPoint<i128, P>
Available on crate feature i128
only.
impl<P: Precision> RoundingMul<FixedPoint<i128, P>> for FixedPoint<i128, P>
i128
only.§type Output = FixedPoint<i128, P>
type Output = FixedPoint<i128, P>
§type Error = ArithmeticError
type Error = ArithmeticError
ArithmeticError
.source§fn rmul(self, rhs: Self, mode: RoundMode) -> Result<Self, ArithmeticError>
fn rmul(self, rhs: Self, mode: RoundMode) -> Result<Self, ArithmeticError>
Err
on overflow.
Because of provided RoundMode
it’s possible to perform across the FixedPoint
values. Read moresource§impl<P: Precision> RoundingMul<FixedPoint<i16, P>> for FixedPoint<i16, P>
Available on crate feature i16
only.
impl<P: Precision> RoundingMul<FixedPoint<i16, P>> for FixedPoint<i16, P>
i16
only.§type Output = FixedPoint<i16, P>
type Output = FixedPoint<i16, P>
§type Error = ArithmeticError
type Error = ArithmeticError
ArithmeticError
.source§fn rmul(self, rhs: Self, mode: RoundMode) -> Result<Self, ArithmeticError>
fn rmul(self, rhs: Self, mode: RoundMode) -> Result<Self, ArithmeticError>
Err
on overflow.
Because of provided RoundMode
it’s possible to perform across the FixedPoint
values. Read moresource§impl<P: Precision> RoundingMul<FixedPoint<i32, P>> for FixedPoint<i32, P>
Available on crate feature i32
only.
impl<P: Precision> RoundingMul<FixedPoint<i32, P>> for FixedPoint<i32, P>
i32
only.§type Output = FixedPoint<i32, P>
type Output = FixedPoint<i32, P>
§type Error = ArithmeticError
type Error = ArithmeticError
ArithmeticError
.source§fn rmul(self, rhs: Self, mode: RoundMode) -> Result<Self, ArithmeticError>
fn rmul(self, rhs: Self, mode: RoundMode) -> Result<Self, ArithmeticError>
Err
on overflow.
Because of provided RoundMode
it’s possible to perform across the FixedPoint
values. Read moresource§impl<P: Precision> RoundingMul<FixedPoint<i64, P>> for FixedPoint<i64, P>
Available on crate feature i64
only.
impl<P: Precision> RoundingMul<FixedPoint<i64, P>> for FixedPoint<i64, P>
i64
only.§type Output = FixedPoint<i64, P>
type Output = FixedPoint<i64, P>
§type Error = ArithmeticError
type Error = ArithmeticError
ArithmeticError
.source§fn rmul(self, rhs: Self, mode: RoundMode) -> Result<Self, ArithmeticError>
fn rmul(self, rhs: Self, mode: RoundMode) -> Result<Self, ArithmeticError>
Err
on overflow.
Because of provided RoundMode
it’s possible to perform across the FixedPoint
values. Read moresource§impl<I, P> Serialize for FixedPoint<I, P>where
I: Serialize,
Self: Stringify + Clone,
Available on crate feature serde
only.
impl<I, P> Serialize for FixedPoint<I, P>where I: Serialize, Self: Stringify + Clone,
serde
only.source§impl<P: Precision> TryFrom<f64> for FixedPoint<i128, P>
impl<P: Precision> TryFrom<f64> for FixedPoint<i128, P>
source§fn try_from(value: f64) -> Result<Self, Self::Error>
fn try_from(value: f64) -> Result<Self, Self::Error>
Implementation courtesy of rust_decimal
crate
§type Error = ConvertError
type Error = ConvertError
source§impl<P: Precision> TryFrom<f64> for FixedPoint<i16, P>
impl<P: Precision> TryFrom<f64> for FixedPoint<i16, P>
source§fn try_from(value: f64) -> Result<Self, Self::Error>
fn try_from(value: f64) -> Result<Self, Self::Error>
Implementation courtesy of rust_decimal
crate
§type Error = ConvertError
type Error = ConvertError
source§impl<P: Precision> TryFrom<f64> for FixedPoint<i32, P>
impl<P: Precision> TryFrom<f64> for FixedPoint<i32, P>
source§fn try_from(value: f64) -> Result<Self, Self::Error>
fn try_from(value: f64) -> Result<Self, Self::Error>
Implementation courtesy of rust_decimal
crate
§type Error = ConvertError
type Error = ConvertError
source§impl<P: Precision> TryFrom<f64> for FixedPoint<i64, P>
impl<P: Precision> TryFrom<f64> for FixedPoint<i64, P>
source§fn try_from(value: f64) -> Result<Self, Self::Error>
fn try_from(value: f64) -> Result<Self, Self::Error>
Implementation courtesy of rust_decimal
crate
§type Error = ConvertError
type Error = ConvertError
impl<I: Copy, P: Copy> Copy for FixedPoint<I, P>
impl<P> EncodeLike<FixedPoint<i128, P>> for FixedPoint<i128, P>
parity
and i128
only.impl<P> EncodeLike<FixedPoint<i16, P>> for FixedPoint<i16, P>
parity
and i16
only.impl<P> EncodeLike<FixedPoint<i32, P>> for FixedPoint<i32, P>
parity
and i32
only.impl<P> EncodeLike<FixedPoint<i64, P>> for FixedPoint<i64, P>
parity
and i64
only.