pub trait Number:
Copy
+ Send
+ Sync
+ IsNone
+ Sized
+ Default
+ Num
+ AddAssign
+ SubAssign
+ MulAssign
+ DivAssign
+ PartialOrd
+ MulAdd
+ Cast<f64>
+ Cast<f32>
+ Cast<usize>
+ Cast<i32>
+ Cast<i64>
+ 'static {
Show 17 methods
// Required methods
fn min_() -> Self;
fn max_() -> Self;
fn abs(self) -> Self;
// Provided methods
fn ceil(self) -> Self { ... }
fn floor(self) -> Self { ... }
fn min_with(self, other: Self) -> Self { ... }
fn max_with(self, other: Self) -> Self { ... }
fn f32(self) -> f32 { ... }
fn f64(self) -> f64 { ... }
fn i32(self) -> i32 { ... }
fn i64(self) -> i64 { ... }
fn usize(self) -> usize { ... }
fn fromas<U>(v: U) -> Self
where U: Number + Cast<Self>,
Self: 'static { ... }
fn to<T: Number>(self) -> T
where Self: Cast<T> { ... }
fn kh_sum(self, v: Self, c: &mut Self) -> Self { ... }
fn n_add(self, other: Self, n: &mut usize) -> Self { ... }
fn n_prod(self, other: Self, n: &mut usize) -> Self { ... }
}Expand description
A trait representing numeric types with various operations and conversions.
This trait combines several other traits and provides additional functionality for numeric types. It includes operations for arithmetic, comparison, conversion, and special numeric functions.
§Type Constraints
The type implementing this trait must satisfy the following constraints:
Copy: The type can be copied bit-for-bit.Send: The type can be safely transferred across thread boundaries.Sync: The type can be safely shared between threads.IsNone: The type has a concept of a “none” value.Sized: The type has a known size at compile-time.Default: The type has a default value.Num: The type supports basic numeric operations.AddAssign,SubAssign,MulAssign,DivAssign: The type supports compound assignment operations.PartialOrd: The type can be partially ordered.MulAdd: The type supports fused multiply-add operations.Cast<f64>,Cast<f32>,Cast<usize>,Cast<i32>,Cast<i64>: The type can be cast to these numeric types.'static: The type has a static lifetime.
Required Methods§
Provided Methods§
sourcefn ceil(self) -> Self
fn ceil(self) -> Self
Computes the ceiling of the number.
For integer types, this is typically the identity function.
sourcefn floor(self) -> Self
fn floor(self) -> Self
Computes the floor of the number.
For integer types, this is typically the identity function.
sourcefn kh_sum(self, v: Self, c: &mut Self) -> Self
fn kh_sum(self, v: Self, c: &mut Self) -> Self
Performs Kahan summation.
This method implements the Kahan summation algorithm, which helps reduce numerical error in the sum of a sequence of floating point numbers.
Object Safety§
This trait is not object safe.