pub struct F32(pub f32);
Expand description
32-bit floating point wrapper which implements fast approximation-based operations.
Tuple Fields§
§0: f32
Implementations§
Source§impl 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
.
Source§impl 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)
.
Source§impl 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§
Source§impl AddAssign<F32> for f32
impl AddAssign<F32> for f32
Source§fn add_assign(&mut self, rhs: F32)
fn add_assign(&mut self, rhs: F32)
+=
operation. Read moreSource§impl AddAssign<f32> for F32
impl AddAssign<f32> for F32
Source§fn add_assign(&mut self, rhs: f32)
fn add_assign(&mut self, rhs: f32)
+=
operation. Read moreSource§impl AddAssign for F32
impl AddAssign for F32
Source§fn add_assign(&mut self, rhs: F32)
fn add_assign(&mut self, rhs: F32)
+=
operation. Read moreSource§impl DivAssign<F32> for f32
impl DivAssign<F32> for f32
Source§fn div_assign(&mut self, rhs: F32)
fn div_assign(&mut self, rhs: F32)
/=
operation. Read moreSource§impl DivAssign<f32> for F32
impl DivAssign<f32> for F32
Source§fn div_assign(&mut self, rhs: f32)
fn div_assign(&mut self, rhs: f32)
/=
operation. Read moreSource§impl DivAssign for F32
impl DivAssign for F32
Source§fn div_assign(&mut self, rhs: F32)
fn div_assign(&mut self, rhs: F32)
/=
operation. Read moreSource§impl MulAssign<F32> for f32
impl MulAssign<F32> for f32
Source§fn mul_assign(&mut self, rhs: F32)
fn mul_assign(&mut self, rhs: F32)
*=
operation. Read moreSource§impl MulAssign<f32> for F32
impl MulAssign<f32> for F32
Source§fn mul_assign(&mut self, rhs: f32)
fn mul_assign(&mut self, rhs: f32)
*=
operation. Read moreSource§impl MulAssign for F32
impl MulAssign for F32
Source§fn mul_assign(&mut self, rhs: F32)
fn mul_assign(&mut self, rhs: F32)
*=
operation. Read moreSource§impl PartialOrd<F32> for f32
impl PartialOrd<F32> for f32
Source§impl PartialOrd<f32> for F32
impl PartialOrd<f32> for F32
Source§impl PartialOrd for F32
impl PartialOrd for F32
Source§impl RemAssign<f32> for F32
impl RemAssign<f32> for F32
Source§fn rem_assign(&mut self, rhs: f32)
fn rem_assign(&mut self, rhs: f32)
%=
operation. Read moreSource§impl RemAssign for F32
impl RemAssign for F32
Source§fn rem_assign(&mut self, rhs: F32)
fn rem_assign(&mut self, rhs: F32)
%=
operation. Read moreSource§impl SubAssign<F32> for f32
impl SubAssign<F32> for f32
Source§fn sub_assign(&mut self, rhs: F32)
fn sub_assign(&mut self, rhs: F32)
-=
operation. Read moreSource§impl SubAssign<f32> for F32
impl SubAssign<f32> for F32
Source§fn sub_assign(&mut self, rhs: f32)
fn sub_assign(&mut self, rhs: f32)
-=
operation. Read moreSource§impl SubAssign for F32
impl SubAssign for F32
Source§fn sub_assign(&mut self, rhs: F32)
fn sub_assign(&mut self, rhs: F32)
-=
operation. Read moreimpl Copy for F32
impl StructuralPartialEq for F32
Auto Trait Implementations§
impl Freeze for F32
impl RefUnwindSafe for F32
impl Send for F32
impl Sync for F32
impl Unpin for F32
impl UnwindSafe for F32
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dst: *mut u8)
unsafe fn clone_to_uninit(&self, dst: *mut u8)
clone_to_uninit
)