Trait FloatLike

Source
pub trait FloatLike:
    Copy
    + Display
    + Debug
    + PartialOrd
    + PartialEq
    + Add<Output = Self>
    + Sub<Output = Self>
    + Mul<Output = Self>
    + Div<Output = Self>
    + Neg<Output = Self>
    + Sum<Self>
    + Product<Self>
    + SubAssign
    + AddAssign
    + MulAssign {
    const MAX: Self;
Show 13 methods // Required methods fn zero() -> Self; fn one() -> Self; fn powf(self, n: Self) -> Self; fn abs(&self) -> Self; fn min(self, other: Self) -> Self; fn max(self, other: Self) -> Self; fn from_u16(n: u16) -> Self; fn from_usize(n: usize) -> Self; fn from_i32(n: i32) -> Self; fn from_f32(n: f32) -> Self; fn round_with_mode( &self, dp: u32, mode: RoundingMode, epsilon: Self, ) -> Self; // Provided methods fn two() -> Self { ... } fn is_zero(&self) -> bool { ... }
}
Expand description

The FloatLike trait is designed to abstract over any fractional numeric type. By default, it supports f32, f64, and rust_decimal’s Decimal. This allows for the generic implementation of the mathematical operations supported by this library.

Required Associated Constants§

Source

const MAX: Self

Required Methods§

Source

fn zero() -> Self

Source

fn one() -> Self

Source

fn powf(self, n: Self) -> Self

Source

fn abs(&self) -> Self

Source

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

Source

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

Source

fn from_u16(n: u16) -> Self

Source

fn from_usize(n: usize) -> Self

Source

fn from_i32(n: i32) -> Self

Source

fn from_f32(n: f32) -> Self

Source

fn round_with_mode(&self, dp: u32, mode: RoundingMode, epsilon: Self) -> Self

Provided Methods§

Source

fn two() -> Self

Source

fn is_zero(&self) -> bool

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl FloatLike for f32

Source§

const MAX: Self = 3.40282347E+38f32

Source§

fn zero() -> Self

Source§

fn one() -> Self

Source§

fn powf(self, n: Self) -> Self

Source§

fn abs(&self) -> Self

Source§

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

Source§

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

Source§

fn from_u16(n: u16) -> Self

Source§

fn from_usize(n: usize) -> Self

Source§

fn from_i32(n: i32) -> Self

Source§

fn from_f32(n: f32) -> Self

Source§

fn round_with_mode(&self, dp: u32, mode: RoundingMode, epsilon: Self) -> Self

Source§

impl FloatLike for f64

Source§

const MAX: Self = 1.7976931348623157E+308f64

Source§

fn zero() -> Self

Source§

fn one() -> Self

Source§

fn powf(self, n: Self) -> Self

Source§

fn abs(&self) -> Self

Source§

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

Source§

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

Source§

fn from_u16(n: u16) -> Self

Source§

fn from_usize(n: usize) -> Self

Source§

fn from_i32(n: i32) -> Self

Source§

fn from_f32(n: f32) -> Self

Source§

fn round_with_mode(&self, dp: u32, mode: RoundingMode, epsilon: Self) -> Self

Implementors§

Source§

impl FloatLike for Decimal

Source§

const MAX: Self = Decimal::MAX