Float

Trait Float 

Source
pub trait Float: Signed {
Show 22 associated constants and 10 methods const PI: Self; const PI_OVER_2: Self; const PI_OVER_4: Self; const TAU: Self; const SQRT_2: Self; const ONE_OVER_SQRT_2: Self; const NEG_ONE_OVER_SQRT_2: Self; const NEG_SQRT_2: Self; const EIGHTH: Self; const QUARTER: Self; const HALF: Self; const NUM_30: Self; const NUM_45: Self; const NUM_60: Self; const NUM_90: Self; const NUM_120: Self; const NUM_135: Self; const NUM_180: Self; const NUM_240: Self; const NUM_255: Self; const NUM_300: Self; const NUM_360: Self; // Required methods fn round(x: Self) -> Self; fn floor(x: Self) -> Self; fn ceil(x: Self) -> Self; fn sqrt(x: Self) -> Self; fn to_radians(x: Self) -> Self; fn to_degrees(x: Self) -> Self; fn atan2(y: Self, x: Self) -> Self; fn sin_cos(x: Self) -> (Self, Self); fn trunc(x: Self) -> Self; fn exp(x: Self) -> Self;
}
Expand description

A primitive floating point number type.

Required Associated Constants§

Source

const PI: Self

Source

const PI_OVER_2: Self

Source

const PI_OVER_4: Self

Source

const TAU: Self

Source

const SQRT_2: Self

Source

const ONE_OVER_SQRT_2: Self

Source

const NEG_ONE_OVER_SQRT_2: Self

Source

const NEG_SQRT_2: Self

Source

const EIGHTH: Self

Source

const QUARTER: Self

Source

const HALF: Self

Source

const NUM_30: Self

Source

const NUM_45: Self

Source

const NUM_60: Self

Source

const NUM_90: Self

Source

const NUM_120: Self

Source

const NUM_135: Self

Source

const NUM_180: Self

Source

const NUM_240: Self

Source

const NUM_255: Self

Source

const NUM_300: Self

Source

const NUM_360: Self

Required Methods§

Source

fn round(x: Self) -> Self

Round to the nearest integer.

Source

fn floor(x: Self) -> Self

Round down to the nearest integer.

Source

fn ceil(x: Self) -> Self

Round up to the nearest integer.

Source

fn sqrt(x: Self) -> Self

Return the number’s square root.

Source

fn to_radians(x: Self) -> Self

Convert from degrees to radians.

Source

fn to_degrees(x: Self) -> Self

Convert from radians to degrees.

Source

fn atan2(y: Self, x: Self) -> Self

Computes the four quadrant arctangent of y and x in radians.

Source

fn sin_cos(x: Self) -> (Self, Self)

Simultaneously computes the sine and cosine of the number, x. Returns (sin(x), cos(x)).

Source

fn trunc(x: Self) -> Self

Returns the integer part of the number. This means that non-integer numbers are always truncated towards zero.

Source

fn exp(x: Self) -> Self

Returns e^(x), (the exponential function).

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

Source§

const PI: Self = 3.14159274f32

Source§

const PI_OVER_2: Self = 1.57079637f32

Source§

const PI_OVER_4: Self = 0.785398185f32

Source§

const TAU: Self = 6.28318548f32

Source§

const SQRT_2: Self = 1.41421354f32

Source§

const ONE_OVER_SQRT_2: Self = 0.707106769f32

Source§

const NEG_ONE_OVER_SQRT_2: Self = -0.707106769f32

Source§

const NEG_SQRT_2: Self = -1.41421354f32

Source§

const EIGHTH: Self = 0.125f32

Source§

const QUARTER: Self = 0.25f32

Source§

const HALF: Self = 0.5f32

Source§

const NUM_30: Self = 30f32

Source§

const NUM_45: Self = 45f32

Source§

const NUM_60: Self = 60f32

Source§

const NUM_90: Self = 90f32

Source§

const NUM_120: Self = 120f32

Source§

const NUM_135: Self = 135f32

Source§

const NUM_180: Self = 180f32

Source§

const NUM_240: Self = 240f32

Source§

const NUM_255: Self = 255f32

Source§

const NUM_300: Self = 300f32

Source§

const NUM_360: Self = 360f32

Source§

fn round(x: Self) -> Self

Source§

fn floor(x: Self) -> Self

Source§

fn ceil(x: Self) -> Self

Source§

fn sqrt(x: Self) -> Self

Source§

fn to_radians(x: Self) -> Self

Source§

fn to_degrees(x: Self) -> Self

Source§

fn atan2(y: Self, x: Self) -> Self

Source§

fn sin_cos(x: Self) -> (Self, Self)

Source§

fn trunc(x: Self) -> Self

Source§

fn exp(x: Self) -> Self

Source§

impl Float for f64

Source§

const PI: Self = 3.1415926535897931f64

Source§

const PI_OVER_2: Self = 1.5707963267948966f64

Source§

const PI_OVER_4: Self = 0.78539816339744828f64

Source§

const TAU: Self = 6.2831853071795862f64

Source§

const SQRT_2: Self = 1.4142135623730951f64

Source§

const ONE_OVER_SQRT_2: Self = 0.70710678118654757f64

Source§

const NEG_ONE_OVER_SQRT_2: Self = -0.70710678118654757f64

Source§

const NEG_SQRT_2: Self = -1.4142135623730951f64

Source§

const EIGHTH: Self = 0.125f64

Source§

const QUARTER: Self = 0.25f64

Source§

const HALF: Self = 0.5f64

Source§

const NUM_30: Self = 30f64

Source§

const NUM_45: Self = 45f64

Source§

const NUM_60: Self = 60f64

Source§

const NUM_90: Self = 90f64

Source§

const NUM_120: Self = 120f64

Source§

const NUM_135: Self = 135f64

Source§

const NUM_180: Self = 180f64

Source§

const NUM_240: Self = 240f64

Source§

const NUM_255: Self = 255f64

Source§

const NUM_300: Self = 300f64

Source§

const NUM_360: Self = 360f64

Source§

fn round(x: Self) -> Self

Source§

fn floor(x: Self) -> Self

Source§

fn ceil(x: Self) -> Self

Source§

fn sqrt(x: Self) -> Self

Source§

fn to_radians(x: Self) -> Self

Source§

fn to_degrees(x: Self) -> Self

Source§

fn atan2(y: Self, x: Self) -> Self

Source§

fn sin_cos(x: Self) -> (Self, Self)

Source§

fn trunc(x: Self) -> Self

Source§

fn exp(x: Self) -> Self

Implementors§