slvm::float

Struct F56

Source
pub struct F56(pub [u8; 7]);
Expand description

The F56 struct represents a 56-bit floating point number using 7 bytes. Most operations on F56 are done by converting to f64, performing the operation, and then converting back to F56

F56 uses 1 bit for the sign, 10 bits for the exponent, and 45 bits for the mantissa. Compared to f32, it has +2 exponent bits and +22 mantissa bits. Compared to f64, it has -1 exponent bit and -7 mantissa bits. Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 [sEEEEEEE][EEEmmmmm][mmmmmmmm][mmmmmmmm][mmmmmmmm][mmmmmmmm][mmmmmmmm]]

Exponent bits range from 0 to 1023 they represent -511 to +512 but are stored biased by +511 the exponent of -511 is reserved for the number 0 and subnormal numbers the exponent of +512 is reserved for infinity and NaN so normal exponents range from -510 to +511

smallest positive subnormal value is 8.48e-168 (2^-555) smallest positive normal value is 2.98e-154 (2^-510) maximum finite value is 1.34e154

A f64 number like 1.00000000001 with 12 decimal digits will be 1.000000000001 A f64 number like 1.000000000001 with 13 decimal digits will be converted to 1.0

Tuple Fields§

§0: [u8; 7]

Implementations§

Source§

impl F56

Source

pub const MAX: F56 = _

Source

pub const MIN_POSITIVE: F56 = _

Source

pub const MIN_POSITIVE_SUBNORMAL: F56 = _

Source

pub const DIGITS: usize = 12usize

Source

pub const EPSILON: f64 = 1.0E-10f64

Source

pub const ROUNDUP_ENABLED: bool = false

Source§

impl F56

Source

pub fn round_f64_to_7_sig_figs(raw_f64: f64) -> f64

Source

pub fn round_f64_to_f56_precision(raw_f64: f64) -> f64

Source

pub fn roughly_equal_using_rounding_sig_figs(&self, other: &F56) -> bool

Returns true if the two F56s’s decimal forms are equal to 7 significant figures This is a lenient type of equality suitable for human use It preserves transitivity, reflexivity, and symmetry It meets the requirements of the Eq trait

Source

pub fn roughly_equal_using_relative_difference(&self, other: &F56) -> bool

Returns true if the relative difference between the two F56s is less than F56::EPSILON This is a lenient type of equality suitable for human use It preserves reflexivity, and symmetry but not transitivity It does not meet the requirements of the Eq trait The relative difference is the absolute difference divided by the larger of the two numbers

Source

pub fn strictest_equal(&self, other: &F56) -> bool

Returns true if the two F56s are bitwise identical

Source

pub fn hash_for_strictest_equal(&self) -> u64

Source

pub fn strictly_equal_except_nan_and_0(&self, other: &F56) -> bool

Returns true if the two F56s are bitwise identical OR if they are both NaN or both 0

Source

pub fn hash_for_strictly_equal_except_nan_and_0(&self) -> u64

Source

pub fn is_nan(&self) -> bool

Returns true if the F56 is NaN. Note that there are many bit patterns that represent NaN

Trait Implementations§

Source§

impl Clone for F56

Source§

fn clone(&self) -> F56

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for F56

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for F56

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<F56> for f32

Source§

fn from(f: F56) -> f32

Converts to this type from the input type.
Source§

impl From<F56> for f64

Source§

fn from(f: F56) -> f64

Converts to this type from the input type.
Source§

impl From<f32> for F56

Source§

fn from(f: f32) -> F56

Converts to this type from the input type.
Source§

impl From<f64> for F56

Source§

fn from(f: f64) -> F56

Converts to this type from the input type.
Source§

impl FromStr for F56

Source§

type Err = ParseFloatError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for F56

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for F56

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for F56

Source§

impl Eq for F56

Auto Trait Implementations§

§

impl Freeze for F56

§

impl RefUnwindSafe for F56

§

impl Send for F56

§

impl Sync for F56

§

impl Unpin for F56

§

impl UnwindSafe for F56

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.