#[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§

source§

impl Ieee32

source

pub fn with_bits(x: u32) -> Self

Create a new Ieee32 containing the bits of x.

source

pub fn pow2<I: Into<i32>>(n: I) -> Self

Create an Ieee32 number representing 2.0^n.

source

pub fn fcvt_to_sint_negative_overflow<I: Into<i32>>(n: I) -> Self

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

source

pub fn neg(self) -> Self

Return self negated.

source

pub fn with_float(x: f32) -> Self

Create a new Ieee32 representing the number x.

source

pub fn bits(self) -> u32

Get the bitwise representation.

source

pub fn is_nan(&self) -> bool

Check if the value is a NaN.

source

pub fn as_f32(self) -> f32

Converts Self to a rust f32

source

pub fn sqrt(self) -> Self

Returns the square root of self.

source

pub fn abs(self) -> Self

Computes the absolute value of self.

source

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

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

source

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.

source

pub fn is_zero(&self) -> bool

Returns true if self is positive or negative zero

source

pub fn ceil(self) -> Self

Returns the smallest integer greater than or equal to self.

source

pub fn floor(self) -> Self

Returns the largest integer less than or equal to self.

source

pub fn trunc(self) -> Self

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

source

pub fn round_ties_even(self) -> Self

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

Trait Implementations§

source§

impl Add<Ieee32> for Ieee32

§

type Output = Ieee32

The resulting type after applying the + operator.
source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
source§

impl BitAnd<Ieee32> for Ieee32

§

type Output = Ieee32

The resulting type after applying the & operator.
source§

fn bitand(self, rhs: Self) -> Self::Output

Performs the & operation. Read more
source§

impl BitOr<Ieee32> for Ieee32

§

type Output = Ieee32

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: Self) -> Self::Output

Performs the | operation. Read more
source§

impl BitXor<Ieee32> for Ieee32

§

type Output = Ieee32

The resulting type after applying the ^ operator.
source§

fn bitxor(self, rhs: Self) -> Self::Output

Performs the ^ operation. Read more
source§

impl Clone for Ieee32

source§

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
source§

impl Debug for Ieee32

source§

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

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

impl Display for Ieee32

source§

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

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

impl Div<Ieee32> for Ieee32

§

type Output = Ieee32

The resulting type after applying the / operator.
source§

fn div(self, rhs: Self) -> Self::Output

Performs the / operation. Read more
source§

impl From<Ieee32> for DataValue

source§

fn from(data: Ieee32) -> Self

Converts to this type from the input type.
source§

impl From<f32> for Ieee32

source§

fn from(x: f32) -> Self

Converts to this type from the input type.
source§

impl FromStr for Ieee32

§

type Err = &'static str

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

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

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

impl Hash for Ieee32

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 IntoBytes for Ieee32

source§

fn into_bytes(self) -> Vec<u8>

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

impl Mul<Ieee32> for Ieee32

§

type Output = Ieee32

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
source§

impl Neg for Ieee32

§

type Output = Ieee32

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl Not for Ieee32

§

type Output = Ieee32

The resulting type after applying the ! operator.
source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
source§

impl PartialEq<Ieee32> for Ieee32

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<Ieee32> for Ieee32

source§

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

This method 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

This method 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

This method 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

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

impl Sub<Ieee32> for Ieee32

§

type Output = Ieee32

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
source§

impl TryInto<Ieee32> for DataValue

§

type Error = DataValueCastFailure

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

fn try_into(self) -> Result<Ieee32, Self::Error>

Performs the conversion.
source§

impl Copy for Ieee32

source§

impl Eq for Ieee32

source§

impl StructuralEq for Ieee32

source§

impl StructuralPartialEq for Ieee32

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

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

source§

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

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

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

source§

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 Twhere 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 Twhere T: Clone,

§

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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.