Trait Float

Source
pub trait Float<T>: ArithmeticOps<T> {
    // Required methods
    fn abs(self) -> T;
    fn floor(self) -> T;
    fn ceil(self) -> T;
    fn trunc(self) -> T;
    fn round(self) -> T;
    fn nearest(self) -> T;
    fn sqrt(self) -> T;
    fn is_sign_positive(self) -> bool;
    fn is_sign_negative(self) -> bool;
    fn min(self, other: T) -> T;
    fn max(self, other: T) -> T;
    fn copysign(self, other: T) -> T;
}
Expand description

Float-point value.

Required Methods§

Source

fn abs(self) -> T

Get absolute value.

Source

fn floor(self) -> T

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

Source

fn ceil(self) -> T

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

Source

fn trunc(self) -> T

Returns the integer part of a number.

Source

fn round(self) -> T

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

Source

fn nearest(self) -> T

Returns the nearest integer to a number. Ties are round to even number.

Source

fn sqrt(self) -> T

Takes the square root of a number.

Source

fn is_sign_positive(self) -> bool

Returns true if the sign of the number is positive.

Source

fn is_sign_negative(self) -> bool

Returns true if the sign of the number is negative.

Source

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

Returns the minimum of the two numbers.

Source

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

Returns the maximum of the two numbers.

Source

fn copysign(self, other: T) -> T

Sets sign of this value to the sign of other value.

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

Source§

fn abs(self) -> f32

Source§

fn floor(self) -> f32

Source§

fn ceil(self) -> f32

Source§

fn trunc(self) -> f32

Source§

fn round(self) -> f32

Source§

fn nearest(self) -> f32

Source§

fn sqrt(self) -> f32

Source§

fn is_sign_positive(self) -> bool

Source§

fn is_sign_negative(self) -> bool

Source§

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

Source§

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

Source§

fn copysign(self, other: f32) -> f32

Source§

impl Float<f64> for f64

Source§

fn abs(self) -> f64

Source§

fn floor(self) -> f64

Source§

fn ceil(self) -> f64

Source§

fn trunc(self) -> f64

Source§

fn round(self) -> f64

Source§

fn nearest(self) -> f64

Source§

fn sqrt(self) -> f64

Source§

fn is_sign_positive(self) -> bool

Source§

fn is_sign_negative(self) -> bool

Source§

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

Source§

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

Source§

fn copysign(self, other: f64) -> f64

Implementors§