pub struct Posit<const N: u32, const ES: u32, Int: Int>(/* private fields */);Expand description
A posit floating point number with N bits and ES exponent bits, using Int as its
underlying type.
§Examples:
type Foo = Posit::<32, 2, i32>; // A 32-bit posit with 2-bit exponent field, represented in a
// 32-bit machine type
type Bar = Posit::<6, 1, i8>; // A 6-bit posit with 1-bit exponent field, represented in an
// 8-bit machine type.Type aliases are provided at the crate root for the posit types defined in the standard.
Implementations§
Source§impl<const N: u32, const ES: u32, Int: Int> Posit<N, ES, Int>
impl<const N: u32, const ES: u32, Int: Int> Posit<N, ES, Int>
Sourcepub const BITS: u32
pub const BITS: u32
The size of this Posit type in bits.
Note: this is the logical size, not necessarily the size of the underlying type.
Sourcepub fn from_bits(x: Int) -> Self
pub fn from_bits(x: Int) -> Self
Construct a posit from its raw bit representation. Bits higher (more significant) than the
lowest N (Self::BITS) bits, if any, are ignored.
Sourcepub const unsafe fn from_bits_unchecked(x: Int) -> Self
pub const unsafe fn from_bits_unchecked(x: Int) -> Self
As Self::from_bits, but if x is not a result of a Self::to_bits call, then calling
this function is undefined behaviour.
Sourcepub const fn to_bits(self) -> Int
pub const fn to_bits(self) -> Int
Return the underlying bit representation of self as a machine int. Bits higher
(more significant) than the lowest N (Self::BITS) bits, if any, are set as equal to
the N-1th bit (i.e. sign-extended).
Source§impl<const N: u32, const ES: u32, Int: Int> Posit<N, ES, Int>
impl<const N: u32, const ES: u32, Int: Int> Posit<N, ES, Int>
Sourcepub const MIN: Self
pub const MIN: Self
Smallest representable value, equal to -MAX.
Not to be confused with the smallest absolute value, i.e. Self::MIN_POSITIVE.
Sourcepub const MIN_POSITIVE: Self
pub const MIN_POSITIVE: Self
Smallest positive value, equal to -MAX_NEGATIVE.
Sourcepub const MAX_NEGATIVE: Self
pub const MAX_NEGATIVE: Self
Largest negative value, equal to -MIN_POSITIVE.
Sourcepub const MIN_EXP: Int
pub const MIN_EXP: Int
The minimum exponent; Self::MIN_POSITIVE = 2 Self::MIN_EXP.
Sourcepub const MAX_EXP: Int
pub const MAX_EXP: Int
The maximum exponent; Self::MAX_NEGATIVE = 2 Self::MAX_EXP.
Trait Implementations§
Source§impl<const N: u32, const ES: u32, Int: Int> AddAssign<&Posit<N, ES, Int>> for Posit<N, ES, Int>
impl<const N: u32, const ES: u32, Int: Int> AddAssign<&Posit<N, ES, Int>> for Posit<N, ES, Int>
Source§fn add_assign(&mut self, rhs: &Posit<N, ES, Int>)
fn add_assign(&mut self, rhs: &Posit<N, ES, Int>)
+= operation. Read moreSource§impl<const N: u32, const ES: u32, Int: Int, const SIZE: usize> AddAssign<&Posit<N, ES, Int>> for Quire<N, ES, SIZE>
impl<const N: u32, const ES: u32, Int: Int, const SIZE: usize> AddAssign<&Posit<N, ES, Int>> for Quire<N, ES, SIZE>
Source§fn add_assign(&mut self, rhs: &Posit<N, ES, Int>)
fn add_assign(&mut self, rhs: &Posit<N, ES, Int>)
+= operation. Read moreSource§impl<const N: u32, const ES: u32, Int: Int, const SIZE: usize> AddAssign<Posit<N, ES, Int>> for Quire<N, ES, SIZE>
impl<const N: u32, const ES: u32, Int: Int, const SIZE: usize> AddAssign<Posit<N, ES, Int>> for Quire<N, ES, SIZE>
Source§fn add_assign(&mut self, rhs: Posit<N, ES, Int>)
fn add_assign(&mut self, rhs: Posit<N, ES, Int>)
+= operation. Read moreSource§impl<const N: u32, const ES: u32, Int: Int> AddAssign for Posit<N, ES, Int>
impl<const N: u32, const ES: u32, Int: Int> AddAssign for Posit<N, ES, Int>
Source§fn add_assign(&mut self, rhs: Posit<N, ES, Int>)
fn add_assign(&mut self, rhs: Posit<N, ES, Int>)
+= operation. Read moreSource§impl<const N: u32, const ES: u32, Int: Int> DivAssign<&Posit<N, ES, Int>> for Posit<N, ES, Int>
impl<const N: u32, const ES: u32, Int: Int> DivAssign<&Posit<N, ES, Int>> for Posit<N, ES, Int>
Source§fn div_assign(&mut self, rhs: &Posit<N, ES, Int>)
fn div_assign(&mut self, rhs: &Posit<N, ES, Int>)
/= operation. Read moreSource§impl<const N: u32, const ES: u32, Int: Int> DivAssign for Posit<N, ES, Int>
impl<const N: u32, const ES: u32, Int: Int> DivAssign for Posit<N, ES, Int>
Source§fn div_assign(&mut self, rhs: Posit<N, ES, Int>)
fn div_assign(&mut self, rhs: Posit<N, ES, Int>)
/= operation. Read moreSource§impl<const N: u32, const ES: u32, Int: Int, const SIZE: usize> From<Posit<N, ES, Int>> for Quire<N, ES, SIZE>
impl<const N: u32, const ES: u32, Int: Int, const SIZE: usize> From<Posit<N, ES, Int>> for Quire<N, ES, SIZE>
Source§impl<const N: u32, const ES: u32, Int: Int> MulAssign<&Posit<N, ES, Int>> for Posit<N, ES, Int>
impl<const N: u32, const ES: u32, Int: Int> MulAssign<&Posit<N, ES, Int>> for Posit<N, ES, Int>
Source§fn mul_assign(&mut self, rhs: &Posit<N, ES, Int>)
fn mul_assign(&mut self, rhs: &Posit<N, ES, Int>)
*= operation. Read moreSource§impl<const N: u32, const ES: u32, Int: Int> MulAssign for Posit<N, ES, Int>
impl<const N: u32, const ES: u32, Int: Int> MulAssign for Posit<N, ES, Int>
Source§fn mul_assign(&mut self, rhs: Posit<N, ES, Int>)
fn mul_assign(&mut self, rhs: Posit<N, ES, Int>)
*= operation. Read moreSource§impl<const N: u32, const ES: u32, Int: Ord + Int> Ord for Posit<N, ES, Int>
impl<const N: u32, const ES: u32, Int: Ord + Int> Ord for Posit<N, ES, Int>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<const N: u32, const ES: u32, Int: PartialOrd + Int> PartialOrd for Posit<N, ES, Int>
impl<const N: u32, const ES: u32, Int: PartialOrd + Int> PartialOrd for Posit<N, ES, Int>
Source§impl<const N: u32, const ES: u32, Int: Int> RoundFrom<f32> for Posit<N, ES, Int>
impl<const N: u32, const ES: u32, Int: Int> RoundFrom<f32> for Posit<N, ES, Int>
Source§fn round_from(value: f32) -> Self
fn round_from(value: f32) -> Self
Convert an f32 into a Posit, rounding according to the standard:
- If the value is any infinity or any NaN, it converts to
NaR. - Otherwise, the float value is rounded (if necessary).
Source§impl<const N: u32, const ES: u32, Int: Int> RoundFrom<f64> for Posit<N, ES, Int>
impl<const N: u32, const ES: u32, Int: Int> RoundFrom<f64> for Posit<N, ES, Int>
Source§fn round_from(value: f64) -> Self
fn round_from(value: f64) -> Self
Convert an f64 into a Posit, rounding according to the standard:
- If the value is any infinity or any NaN, it converts to
NaR. - Otherwise, the float value is rounded (if necessary).
Source§impl<const N: u32, const ES: u32, Int: Int> RoundFrom<i128> for Posit<N, ES, Int>
impl<const N: u32, const ES: u32, Int: Int> RoundFrom<i128> for Posit<N, ES, Int>
Source§fn round_from(value: i128) -> Self
fn round_from(value: i128) -> Self
Convert an i128 into a Posit, rounding according to the standard:
Source§impl<const N: u32, const ES: u32, Int: Int> RoundFrom<i16> for Posit<N, ES, Int>
impl<const N: u32, const ES: u32, Int: Int> RoundFrom<i16> for Posit<N, ES, Int>
Source§fn round_from(value: i16) -> Self
fn round_from(value: i16) -> Self
Convert an i16 into a Posit, rounding according to the standard:
Source§impl<const N: u32, const ES: u32, Int: Int> RoundFrom<i32> for Posit<N, ES, Int>
impl<const N: u32, const ES: u32, Int: Int> RoundFrom<i32> for Posit<N, ES, Int>
Source§fn round_from(value: i32) -> Self
fn round_from(value: i32) -> Self
Convert an i32 into a Posit, rounding according to the standard:
Source§impl<const N: u32, const ES: u32, Int: Int> RoundFrom<i64> for Posit<N, ES, Int>
impl<const N: u32, const ES: u32, Int: Int> RoundFrom<i64> for Posit<N, ES, Int>
Source§fn round_from(value: i64) -> Self
fn round_from(value: i64) -> Self
Convert an i64 into a Posit, rounding according to the standard:
Source§impl<const N: u32, const ES: u32, Int: Int> RoundFrom<i8> for Posit<N, ES, Int>
impl<const N: u32, const ES: u32, Int: Int> RoundFrom<i8> for Posit<N, ES, Int>
Source§fn round_from(value: i8) -> Self
fn round_from(value: i8) -> Self
Convert an i8 into a Posit, rounding according to the standard:
Source§impl<const N: u32, const ES: u32, Int: Int> SubAssign<&Posit<N, ES, Int>> for Posit<N, ES, Int>
impl<const N: u32, const ES: u32, Int: Int> SubAssign<&Posit<N, ES, Int>> for Posit<N, ES, Int>
Source§fn sub_assign(&mut self, rhs: &Posit<N, ES, Int>)
fn sub_assign(&mut self, rhs: &Posit<N, ES, Int>)
-= operation. Read moreSource§impl<const N: u32, const ES: u32, Int: Int, const SIZE: usize> SubAssign<&Posit<N, ES, Int>> for Quire<N, ES, SIZE>
impl<const N: u32, const ES: u32, Int: Int, const SIZE: usize> SubAssign<&Posit<N, ES, Int>> for Quire<N, ES, SIZE>
Source§fn sub_assign(&mut self, rhs: &Posit<N, ES, Int>)
fn sub_assign(&mut self, rhs: &Posit<N, ES, Int>)
-= operation. Read moreSource§impl<const N: u32, const ES: u32, Int: Int, const SIZE: usize> SubAssign<Posit<N, ES, Int>> for Quire<N, ES, SIZE>
impl<const N: u32, const ES: u32, Int: Int, const SIZE: usize> SubAssign<Posit<N, ES, Int>> for Quire<N, ES, SIZE>
Source§fn sub_assign(&mut self, rhs: Posit<N, ES, Int>)
fn sub_assign(&mut self, rhs: Posit<N, ES, Int>)
-= operation. Read moreSource§impl<const N: u32, const ES: u32, Int: Int> SubAssign for Posit<N, ES, Int>
impl<const N: u32, const ES: u32, Int: Int> SubAssign for Posit<N, ES, Int>
Source§fn sub_assign(&mut self, rhs: Posit<N, ES, Int>)
fn sub_assign(&mut self, rhs: Posit<N, ES, Int>)
-= operation. Read more