cranelift::prelude

Struct Ieee32

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

An IEEE binary32 immediate floating point value, represented as a u32 containing the bit pattern.

We specifically avoid using a f32 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 Ieee32

pub const NAN: Ieee32 = _

The positive WebAssembly canonical NaN.

pub const fn with_bits(bits: u32) -> Ieee32

Create a new Ieee32 containing the bits of bits.

pub fn bits(self) -> u32

Get the bitwise representation.

pub fn with_float(x: f32) -> Ieee32

Create a new Ieee32 representing the number x.

pub fn as_f32(self) -> f32

Converts self to a Rust f32.

pub fn abs(self) -> Ieee32

Computes the absolute value of self.

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

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

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

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

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

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

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

Create an Ieee32 number representing 2.0^n.

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

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

pub fn is_nan(self) -> bool

Check if the value is a NaN. For Ieee32, 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<Ieee32>

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

pub fn sqrt(self) -> Ieee32

Returns the square root of self.

pub fn ceil(self) -> Ieee32

Returns the smallest integer greater than or equal to self.

pub fn floor(self) -> Ieee32

Returns the largest integer less than or equal to self.

pub fn trunc(self) -> Ieee32

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

pub fn round_ties_even(self) -> Ieee32

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

Trait Implementations§

§

impl Add for Ieee32

§

type Output = Ieee32

The resulting type after applying the + operator.
§

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

Performs the + operation. Read more
§

impl BitAnd for Ieee32

§

type Output = Ieee32

The resulting type after applying the & operator.
§

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

Performs the & operation. Read more
§

impl BitOr for Ieee32

§

type Output = Ieee32

The resulting type after applying the | operator.
§

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

Performs the | operation. Read more
§

impl BitXor for Ieee32

§

type Output = Ieee32

The resulting type after applying the ^ operator.
§

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

Performs the ^ operation. Read more
§

impl Clone for Ieee32

§

fn clone(&self) -> Ieee32

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 Ieee32

§

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

Formats the value using the given formatter. Read more
§

impl<'de> Deserialize<'de> for Ieee32

§

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

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

impl Display for Ieee32

§

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

Formats the value using the given formatter. Read more
§

impl Div for Ieee32

§

type Output = Ieee32

The resulting type after applying the / operator.
§

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

Performs the / operation. Read more
§

impl From<f32> for Ieee32

§

fn from(x: f32) -> Ieee32

Converts to this type from the input type.
§

impl FromStr for Ieee32

§

type Err = &'static str

The associated error which can be returned from parsing.
§

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

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

impl Hash for Ieee32

§

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 Ieee32

§

fn into_bytes(self) -> Vec<u8>

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

impl Mul for Ieee32

§

type Output = Ieee32

The resulting type after applying the * operator.
§

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

Performs the * operation. Read more
§

impl Neg for Ieee32

§

type Output = Ieee32

The resulting type after applying the - operator.
§

fn neg(self) -> Ieee32

Performs the unary - operation. Read more
§

impl Not for Ieee32

§

type Output = Ieee32

The resulting type after applying the ! operator.
§

fn not(self) -> Ieee32

Performs the unary ! operation. Read more
§

impl PartialEq for Ieee32

§

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

§

fn partial_cmp(&self, rhs: &Ieee32) -> 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 Ieee32

§

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 Ieee32

§

type Output = Ieee32

The resulting type after applying the - operator.
§

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

Performs the - operation. Read more
§

impl Copy for Ieee32

§

impl Eq for Ieee32

§

impl StructuralPartialEq for Ieee32

Auto Trait Implementations§

§

impl Freeze for Ieee32

§

impl RefUnwindSafe for Ieee32

§

impl Send for Ieee32

§

impl Sync for Ieee32

§

impl Unpin for Ieee32

§

impl UnwindSafe for Ieee32

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>,