ScientificNumber

Trait ScientificNumber 

Source
pub trait ScientificNumber:
    Num
    + Clone
    + Copy
    + PartialOrd
    + Debug
    + Zero
    + One
    + Add<Output = Self>
    + Sub<Output = Self>
    + Mul<Output = Self>
    + Div<Output = Self>
    + AddAssign
    + SubAssign
    + MulAssign
    + DivAssign
    + NumCast {
    // Required methods
    fn abs(self) -> Self;
    fn sqrt(self) -> Self;
    fn max(self, other: Self) -> Self;
    fn min(self, other: Self) -> Self;
    fn is_finite(self) -> bool;
    fn to_f64(self) -> Option<f64>;
    fn from_f64(value: f64) -> Option<Self>;
    fn from_le_bytes(bytes: &[u8]) -> Self;
    fn from_be_bytes(bytes: &[u8]) -> Self;
    fn to_le_bytes(self) -> Vec<u8> ;
    fn to_be_bytes(self) -> Vec<u8> ;

    // Provided method
    fn square(self) -> Self { ... }
}
Expand description

A trait for numeric types that can be used in scientific calculations

This trait combines common numeric traits required for scientific computing operations, providing a unified trait bound for generic code.

Required Methods§

Source

fn abs(self) -> Self

Absolute value

Source

fn sqrt(self) -> Self

Square root

Source

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

Maximum of two values

Source

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

Minimum of two values

Source

fn is_finite(self) -> bool

Check if the value is finite

Source

fn to_f64(self) -> Option<f64>

Convert to f64

Source

fn from_f64(value: f64) -> Option<Self>

Convert from f64

Source

fn from_le_bytes(bytes: &[u8]) -> Self

Convert from little-endian bytes

Source

fn from_be_bytes(bytes: &[u8]) -> Self

Convert from big-endian bytes

Source

fn to_le_bytes(self) -> Vec<u8>

Convert to little-endian bytes

Source

fn to_be_bytes(self) -> Vec<u8>

Convert to big-endian bytes

Provided Methods§

Source

fn square(self) -> Self

Square

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 ScientificNumber for f32

Source§

fn abs(self) -> Self

Source§

fn sqrt(self) -> Self

Source§

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

Source§

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

Source§

fn is_finite(self) -> bool

Source§

fn to_f64(self) -> Option<f64>

Source§

fn from_f64(value: f64) -> Option<Self>

Source§

fn from_le_bytes(bytes: &[u8]) -> Self

Source§

fn from_be_bytes(bytes: &[u8]) -> Self

Source§

fn to_le_bytes(self) -> Vec<u8>

Source§

fn to_be_bytes(self) -> Vec<u8>

Source§

impl ScientificNumber for f64

Source§

fn abs(self) -> Self

Source§

fn sqrt(self) -> Self

Source§

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

Source§

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

Source§

fn is_finite(self) -> bool

Source§

fn to_f64(self) -> Option<f64>

Source§

fn from_f64(value: f64) -> Option<Self>

Source§

fn from_le_bytes(bytes: &[u8]) -> Self

Source§

fn from_be_bytes(bytes: &[u8]) -> Self

Source§

fn to_le_bytes(self) -> Vec<u8>

Source§

fn to_be_bytes(self) -> Vec<u8>

Source§

impl ScientificNumber for i32

Source§

fn abs(self) -> Self

Source§

fn sqrt(self) -> Self

Source§

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

Source§

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

Source§

fn is_finite(self) -> bool

Source§

fn to_f64(self) -> Option<f64>

Source§

fn from_f64(value: f64) -> Option<Self>

Source§

fn from_le_bytes(bytes: &[u8]) -> Self

Source§

fn from_be_bytes(bytes: &[u8]) -> Self

Source§

fn to_le_bytes(self) -> Vec<u8>

Source§

fn to_be_bytes(self) -> Vec<u8>

Implementors§