[][src]Struct bigbit::headbyte::HeadByte

#[repr(transparent)]pub struct HeadByte(_);

The Head Byte itself, containing information about the sign, presence of the exponent and the number of coefficients.

Follows the newtype pattern, meaning that it can be unwrapped into the inner byte.

Methods

impl HeadByte[src]

pub const SIGN_MASK: u8[src]

The sign bit mask.

Use sign to easily retreive the sign.

pub const ABS_MASK: u8[src]

The mask used for retreiving the absolute value of the number.

Use abs or bitwise-AND (&) this with the Head Byte to retreive the absolute value.

pub const HAS_EXPONENT_MASK: u8[src]

The exponent presence bit mask.

Use has_exponent to easily retreive this.

pub const NUM_COEFFICIENTS_MASK: u8[src]

Mask for the number of coefficients.

Use num_coefficients to easily retreive this.

pub const INFINITY: Self[src]

The (positive infinity) value for the Head Byte.

No following exponent or coefficients are allowed in this case, despite the exponent bit being set.

pub const NEG_INFINITY: Self[src]

The -∞ (negative infinity) value for the Head Byte.

No following exponent or coefficients are allowed in this case, despite the exponent bit being set.

pub const ZERO: Self[src]

The zero value. There's no distinction between positive and negative zero.

No following exponent or coefficients are allowed.

pub const NAN: Self[src]

The NaN (Not-a-Number) value. There's no distinction between negative/positive NaN or signalling/quiet NaN. (This implementation always generates quiet NaN.)

NaN values aren't equal to themselves, just like in IEEE 754. To check for NaN values, use either is_nan or, if you're using the try_nan feature (which currently only works on Nightly), the Try trait, which returns an error if the value is NaN.

No following exponent or coefficients are allowed.

#[must_use]pub fn sign(self) -> Sign[src]

Retreives the sign from a Head Byte.

#[must_use]pub fn abs(self) -> Self[src]

Retreives the absolute value from the number whose Head Byte is self.

Since the Head Byte stores the sign of the entire number, it's enough to just perform bitwise AND with the ABS_MASK, which in turn is the bitwise NOT of the sign mask.

#[must_use]pub fn exponent_bit_set(self) -> bool[src]

Checks whether the HAS_EXPONENT bit of the Head Byte is set, meaning either infinity or the presence of an actual exponent.

For a version which also checks for the infinity special case, see has_exponent.

#[must_use]pub fn is_infinite(self) -> bool[src]

Checks whether the Head Byte describes either positive or negative infinity.

This is mostly uesd in has_exponent to check for the infinity special case.

#[must_use]pub fn is_nan(self) -> bool[src]

Checks whether the Head Byte describes a NaN value.

#[must_use]pub fn has_exponent(self) -> bool[src]

Checks whether the Head Byte is supposed to be followed by an exponent byte.

This includes the check for the special infinity value. For a version which does not check for infinity and thus plays more nicely with branch prediction, see exponent_bit_set.

#[must_use]pub fn num_coefficients(self) -> u8[src]

Retreives the number of following coefficients from a Head Byte.

#[must_use]pub fn into_inner(self) -> u8[src]

Consumes the value and returns the inner byte.

Trait Implementations

impl Clone for HeadByte[src]

impl Copy for HeadByte[src]

impl Debug for HeadByte[src]

impl Eq for HeadByte[src]

impl From<HeadByte> for u8[src]

#[must_use]fn from(op: HeadByte) -> Self[src]

Consumes the Head Byte and returns the underlying inner byte.

impl From<u8> for HeadByte[src]

#[must_use]fn from(op: u8) -> Self[src]

Wraps a byte into a Head Byte.

impl Neg for HeadByte[src]

type Output = Self

The resulting type after applying the - operator.

impl PartialEq<HeadByte> for HeadByte[src]

impl StructuralEq for HeadByte[src]

impl StructuralPartialEq for HeadByte[src]

Auto Trait Implementations

impl Send for HeadByte

impl Sync for HeadByte

impl Unpin for HeadByte

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.