Struct ScaledFloat
pub struct ScaledFloat(/* private field */);
An unsigned integer scaled version of a floating point value, equivalent to an integer quotient with [fixed denominator][ScaledFloat::SCALING]).
Implementations
impl ScaledFloat
const SCALING: f32 = 100_000.0;fn in_range(value: f32) -> boolGets whether the value is within the clamped range of this type.
fn exact(value: f32) -> boolGets whether the value can be exactly converted in round-trip.
fn new(value: f32) -> SelfSlightly inaccurate scaling and quantization. Clamps the value into the representable range if it is negative or too large.
fn from_scaled(val: u32) -> SelfFully accurate construction from a value scaled as per specification.
fn into_scaled(self) -> u32Get the accurate encoded value.
fn into_value(self) -> f32Get the unscaled value as a floating point.
Trait Implementations
impl Clone for ScaledFloat
fn clone(&self) -> Self
impl Copy for ScaledFloat
impl Debug for ScaledFloat
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Eq for ScaledFloat
impl PartialEq for ScaledFloat
fn eq(&self, other: &Self) -> bool
impl StructuralPartialEq for ScaledFloat
Auto Trait Implementations
impl Freeze for ScaledFloat
impl RefUnwindSafe for ScaledFloat
impl Send for ScaledFloat
impl Sync for ScaledFloat
impl Unpin for ScaledFloat
impl UnsafeUnpin for ScaledFloat
impl UnwindSafe for ScaledFloat
Blanket Implementations
impl<T> Any for ScaledFloat
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for ScaledFloat
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for ScaledFloat
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for ScaledFloat
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for ScaledFloat
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for ScaledFloat
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T, U> Into<U> for ScaledFloat
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for ScaledFloat
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for ScaledFloat
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>