Skip to main content

Real

Trait Real 

Source
pub trait Real:
    Num
    + Signed
    + Div<Output = Self>
    + Rem<Output = Self>
    + PartialOrd {
Show 17 methods // Required methods fn from_f64(v: f64) -> Self; fn to_f64(self) -> f64; fn epsilon() -> Self; fn sqrt(self) -> Self; fn cbrt(self) -> Self; fn powf(self, e: Self) -> Self; fn powi(self, e: i32) -> Self; fn recip(self) -> Self; fn floor(self) -> Self; fn ceil(self) -> Self; fn round(self) -> Self; fn trunc(self) -> Self; fn fract(self) -> Self; fn copysign(self, other: Self) -> Self; fn abs_sub(self, other: Self) -> Self; fn min(self, other: Self) -> Self; fn max(self, other: Self) -> Self;
}
Expand description

Core real number operations: conversion, powers, rounding, min/max.

Implemented for f32 and f64. This is the minimal trait bound needed by most generic math code.

Required Methods§

Source

fn from_f64(v: f64) -> Self

Convert from f64.

Source

fn to_f64(self) -> f64

Convert to f64.

Source

fn epsilon() -> Self

Machine epsilon for this type.

Source

fn sqrt(self) -> Self

Square root.

Source

fn cbrt(self) -> Self

Cube root.

Source

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

Raise to a floating-point power.

Source

fn powi(self, e: i32) -> Self

Raise to an integer power.

Source

fn recip(self) -> Self

Reciprocal: 1 / self.

Source

fn floor(self) -> Self

Floor: largest integer <= self.

Source

fn ceil(self) -> Self

Ceiling: smallest integer >= self.

Source

fn round(self) -> Self

Round to nearest integer.

Source

fn trunc(self) -> Self

Truncate toward zero.

Source

fn fract(self) -> Self

Fractional part: self - floor(self).

Source

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

Copy the sign of other to the magnitude of self.

Source

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

max(self - other, 0).

Source

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

Minimum of self and other.

Source

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

Maximum of self and other.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Real for f32

Source§

fn from_f64(v: f64) -> Self

Source§

fn to_f64(self) -> f64

Source§

fn epsilon() -> Self

Source§

fn sqrt(self) -> Self

Source§

fn cbrt(self) -> Self

Source§

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

Source§

fn powi(self, e: i32) -> Self

Source§

fn recip(self) -> Self

Source§

fn floor(self) -> Self

Source§

fn ceil(self) -> Self

Source§

fn round(self) -> Self

Source§

fn trunc(self) -> Self

Source§

fn fract(self) -> Self

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl Real for f64

Source§

fn from_f64(v: f64) -> Self

Source§

fn to_f64(self) -> f64

Source§

fn epsilon() -> Self

Source§

fn sqrt(self) -> Self

Source§

fn cbrt(self) -> Self

Source§

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

Source§

fn powi(self, e: i32) -> Self

Source§

fn recip(self) -> Self

Source§

fn floor(self) -> Self

Source§

fn ceil(self) -> Self

Source§

fn round(self) -> Self

Source§

fn trunc(self) -> Self

Source§

fn fract(self) -> Self

Source§

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

Source§

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

Source§

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

Source§

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

Implementors§