cranelift::prelude

Struct Ieee64

#[repr(C)]
pub struct Ieee64 { /* private fields */ }
Expand description

An IEEE binary64 immediate floating point value, represented as a u64 containing the bit pattern.

We specifically avoid using a f64 here since some architectures may silently alter floats. See: https://github.com/bytecodealliance/wasmtime/pull/2251#discussion_r498508646

The PartialEq and Hash implementations are over the underlying bit pattern, but PartialOrd respects IEEE754 semantics.

All bit patterns are allowed.

Implementations§

§

impl Ieee64

pub const NAN: Ieee64 = _

The positive WebAssembly canonical NaN.

pub const fn with_bits(bits: u64) -> Ieee64

Create a new Ieee64 containing the bits of bits.

pub fn bits(self) -> u64

Get the bitwise representation.

pub fn with_float(x: f64) -> Ieee64

Create a new Ieee64 representing the number x.

pub fn as_f64(self) -> f64

Converts self to a Rust f64.

pub fn abs(self) -> Ieee64

Computes the absolute value of self.

pub fn copysign(self, sign: Ieee64) -> Ieee64

Returns a number composed of the magnitude of self and the sign of sign.

pub fn minimum(self, other: Ieee64) -> Ieee64

Returns the minimum of self and other, following the WebAssembly/IEEE 754-2019 definition.

pub fn maximum(self, other: Ieee64) -> Ieee64

Returns the maximum of self and other, following the WebAssembly/IEEE 754-2019 definition.

pub fn pow2<I>(n: I) -> Ieee64
where I: Into<i32>,

Create an Ieee64 number representing 2.0^n.

pub fn fcvt_to_sint_negative_overflow<I>(n: I) -> Ieee64
where I: Into<i32>,

Create an Ieee64 number representing the greatest negative value not convertible from f64 to a signed integer with width n.

pub fn is_nan(self) -> bool

Check if the value is a NaN. For Ieee64, this means checking that all the exponent bits are set and the significand is non-zero.

pub fn is_positive(self) -> bool

Returns true if self has a negative sign, including 0.0, NaNs with positive sign bit and positive infinity.

pub fn is_negative(self) -> bool

Returns true if self has a negative sign, including -0.0, NaNs with negative sign bit and negative infinity.

pub fn is_zero(self) -> bool

Returns true if self is positive or negative zero.

pub fn non_nan(self) -> Option<Ieee64>

Returns None if self is a NaN and Some(self) otherwise.

pub fn sqrt(self) -> Ieee64

Returns the square root of self.

pub fn ceil(self) -> Ieee64

Returns the smallest integer greater than or equal to self.

pub fn floor(self) -> Ieee64

Returns the largest integer less than or equal to self.

pub fn trunc(self) -> Ieee64

Returns the integer part of self. This means that non-integer numbers are always truncated towards zero.

pub fn round_ties_even(self) -> Ieee64

Returns the nearest integer to self. Rounds half-way cases to the number with an even least significant digit.

Trait Implementations§

§

impl Add for Ieee64

§

type Output = Ieee64

The resulting type after applying the + operator.
§

fn add(self, rhs: Ieee64) -> Ieee64

Performs the + operation. Read more
§

impl BitAnd for Ieee64

§

type Output = Ieee64

The resulting type after applying the & operator.
§

fn bitand(self, rhs: Ieee64) -> Ieee64

Performs the & operation. Read more
§

impl BitOr for Ieee64

§

type Output = Ieee64

The resulting type after applying the | operator.
§

fn bitor(self, rhs: Ieee64) -> Ieee64

Performs the | operation. Read more
§

impl BitXor for Ieee64

§

type Output = Ieee64

The resulting type after applying the ^ operator.
§

fn bitxor(self, rhs: Ieee64) -> Ieee64

Performs the ^ operation. Read more
§

impl Clone for Ieee64

§

fn clone(&self) -> Ieee64

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
§

impl Debug for Ieee64

§

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

Formats the value using the given formatter. Read more
§

impl<'de> Deserialize<'de> for Ieee64

§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Ieee64, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
§

impl Display for Ieee64

§

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

Formats the value using the given formatter. Read more
§

impl Div for Ieee64

§

type Output = Ieee64

The resulting type after applying the / operator.
§

fn div(self, rhs: Ieee64) -> <Ieee64 as Div>::Output

Performs the / operation. Read more
§

impl From<f64> for Ieee64

§

fn from(x: f64) -> Ieee64

Converts to this type from the input type.
§

impl FromStr for Ieee64

§

type Err = &'static str

The associated error which can be returned from parsing.
§

fn from_str(s: &str) -> Result<Ieee64, &'static str>

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

impl Hash for Ieee64

§

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

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
§

impl IntoBytes for Ieee64

§

fn into_bytes(self) -> Vec<u8>

Return the little-endian byte representation of the implementing type.
§

impl Mul for Ieee64

§

type Output = Ieee64

The resulting type after applying the * operator.
§

fn mul(self, rhs: Ieee64) -> Ieee64

Performs the * operation. Read more
§

impl Neg for Ieee64

§

type Output = Ieee64

The resulting type after applying the - operator.
§

fn neg(self) -> Ieee64

Performs the unary - operation. Read more
§

impl Not for Ieee64

§

type Output = Ieee64

The resulting type after applying the ! operator.
§

fn not(self) -> Ieee64

Performs the unary ! operation. Read more
§

impl PartialEq for Ieee64

§

fn eq(&self, other: &Ieee64) -> 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.
§

impl PartialOrd for Ieee64

§

fn partial_cmp(&self, rhs: &Ieee64) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
§

impl Serialize for Ieee64

§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
§

impl Sub for Ieee64

§

type Output = Ieee64

The resulting type after applying the - operator.
§

fn sub(self, rhs: Ieee64) -> Ieee64

Performs the - operation. Read more
§

impl Copy for Ieee64

§

impl Eq for Ieee64

§

impl StructuralPartialEq for Ieee64

Auto Trait Implementations§

§

impl Freeze for Ieee64

§

impl RefUnwindSafe for Ieee64

§

impl Send for Ieee64

§

impl Sync for Ieee64

§

impl Unpin for Ieee64

§

impl UnwindSafe for Ieee64

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
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,