pub struct F32(pub f32);
Expand description
32-bit floating point wrapper which implements fast approximation-based operations.
Tuple Fields
0: f32
Implementations
sourceimpl F32
impl F32
sourcepub fn div_euclid(self, rhs: Self) -> Self
pub fn div_euclid(self, rhs: Self) -> Self
Calculates Euclidean division, the matching method for rem_euclid
.
sourceimpl F32
impl F32
sourcepub fn rem_euclid(self, rhs: Self) -> Self
pub fn rem_euclid(self, rhs: Self) -> Self
Calculates the least non-negative remainder of self (mod rhs)
.
sourceimpl F32
impl F32
sourcepub const MANTISSA_DIGITS: u32 = 24u32
pub const MANTISSA_DIGITS: u32 = 24u32
Number of significant digits in base 2.
sourcepub const EPSILON: Self = _
pub const EPSILON: Self = _
Machine epsilon value for f32
.
This is the difference between 1.0
and the next larger representable number.
sourcepub const MIN_POSITIVE: Self = _
pub const MIN_POSITIVE: Self = _
Smallest positive normal f32
value.
sourcepub const MIN_EXP: i32 = -125i32
pub const MIN_EXP: i32 = -125i32
One greater than the minimum possible normal power of 2 exponent.
sourcepub const MIN_10_EXP: i32 = -37i32
pub const MIN_10_EXP: i32 = -37i32
Minimum possible normal power of 10 exponent.
sourcepub const MAX_10_EXP: i32 = 38i32
pub const MAX_10_EXP: i32 = 38i32
Maximum possible power of 10 exponent.
sourcepub const NEG_INFINITY: Self = _
pub const NEG_INFINITY: Self = _
Negative infinity (−∞).
sourcepub fn is_infinite(self) -> bool
pub fn is_infinite(self) -> bool
Returns true
if this value is positive infinity or negative infinity, and
false
otherwise.
sourcepub fn is_sign_positive(self) -> bool
pub fn is_sign_positive(self) -> bool
Returns true
if self
has a positive sign, including +0.0
, NaN
s with
positive sign bit and positive infinity.
sourcepub fn is_sign_negative(self) -> bool
pub fn is_sign_negative(self) -> bool
Returns true
if self
has a negative sign, including -0.0
, NaN
s with
negative sign bit and negative infinity.
sourcepub fn to_bits(self) -> u32
pub fn to_bits(self) -> u32
Raw transmutation to u32
.
This is currently identical to transmute::<f32, u32>(self)
on all platforms.
See F32::from_bits
for some discussion of the portability of this operation
(there are almost no issues).
sourcepub fn from_bits(v: u32) -> Self
pub fn from_bits(v: u32) -> Self
Raw transmutation from u32
.
This is currently identical to transmute::<u32, f32>(v)
on all platforms.
It turns out this is incredibly portable, for two reasons:
- Floats and Ints have the same endianness on all supported platforms.
- IEEE-754 very precisely specifies the bit layout of floats.
See f32::from_bits
for more information.
Trait Implementations
sourceimpl AddAssign<F32> for F32
impl AddAssign<F32> for F32
sourcefn add_assign(&mut self, rhs: F32)
fn add_assign(&mut self, rhs: F32)
Performs the +=
operation. Read more
sourceimpl AddAssign<F32> for f32
impl AddAssign<F32> for f32
sourcefn add_assign(&mut self, rhs: F32)
fn add_assign(&mut self, rhs: F32)
Performs the +=
operation. Read more
sourceimpl AddAssign<f32> for F32
impl AddAssign<f32> for F32
sourcefn add_assign(&mut self, rhs: f32)
fn add_assign(&mut self, rhs: f32)
Performs the +=
operation. Read more
sourceimpl DivAssign<F32> for F32
impl DivAssign<F32> for F32
sourcefn div_assign(&mut self, rhs: F32)
fn div_assign(&mut self, rhs: F32)
Performs the /=
operation. Read more
sourceimpl DivAssign<F32> for f32
impl DivAssign<F32> for f32
sourcefn div_assign(&mut self, rhs: F32)
fn div_assign(&mut self, rhs: F32)
Performs the /=
operation. Read more
sourceimpl DivAssign<f32> for F32
impl DivAssign<f32> for F32
sourcefn div_assign(&mut self, rhs: f32)
fn div_assign(&mut self, rhs: f32)
Performs the /=
operation. Read more
sourceimpl FromStr for F32
impl FromStr for F32
type Err = ParseFloatError
type Err = ParseFloatError
The associated error which can be returned from parsing.
sourceimpl MulAssign<F32> for F32
impl MulAssign<F32> for F32
sourcefn mul_assign(&mut self, rhs: F32)
fn mul_assign(&mut self, rhs: F32)
Performs the *=
operation. Read more
sourceimpl MulAssign<F32> for f32
impl MulAssign<F32> for f32
sourcefn mul_assign(&mut self, rhs: F32)
fn mul_assign(&mut self, rhs: F32)
Performs the *=
operation. Read more
sourceimpl MulAssign<f32> for F32
impl MulAssign<f32> for F32
sourcefn mul_assign(&mut self, rhs: f32)
fn mul_assign(&mut self, rhs: f32)
Performs the *=
operation. Read more
sourceimpl PartialOrd<F32> for F32
impl PartialOrd<F32> for F32
sourcefn partial_cmp(&self, other: &F32) -> Option<Ordering>
fn partial_cmp(&self, other: &F32) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl PartialOrd<F32> for f32
impl PartialOrd<F32> for f32
sourcefn partial_cmp(&self, other: &F32) -> Option<Ordering>
fn partial_cmp(&self, other: &F32) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl PartialOrd<f32> for F32
impl PartialOrd<f32> for F32
sourcefn partial_cmp(&self, other: &f32) -> Option<Ordering>
fn partial_cmp(&self, other: &f32) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl RemAssign<F32> for F32
impl RemAssign<F32> for F32
sourcefn rem_assign(&mut self, rhs: F32)
fn rem_assign(&mut self, rhs: F32)
Performs the %=
operation. Read more
sourceimpl RemAssign<f32> for F32
impl RemAssign<f32> for F32
sourcefn rem_assign(&mut self, rhs: f32)
fn rem_assign(&mut self, rhs: f32)
Performs the %=
operation. Read more
sourceimpl SubAssign<F32> for F32
impl SubAssign<F32> for F32
sourcefn sub_assign(&mut self, rhs: F32)
fn sub_assign(&mut self, rhs: F32)
Performs the -=
operation. Read more
sourceimpl SubAssign<F32> for f32
impl SubAssign<F32> for f32
sourcefn sub_assign(&mut self, rhs: F32)
fn sub_assign(&mut self, rhs: F32)
Performs the -=
operation. Read more
sourceimpl SubAssign<f32> for F32
impl SubAssign<f32> for F32
sourcefn sub_assign(&mut self, rhs: f32)
fn sub_assign(&mut self, rhs: f32)
Performs the -=
operation. Read more
impl Copy for F32
impl StructuralPartialEq for F32
Auto Trait Implementations
impl RefUnwindSafe for F32
impl Send for F32
impl Sync for F32
impl Unpin for F32
impl UnwindSafe for F32
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more