pub struct LongDouble(/* private fields */);Expand description
A long double value, kept as its IEEE 754 binary128 bits: the sign
in the top bit, a 15-bit exponent biased by 16383 and a 112-bit
fraction.
Rust has no 128-bit float, so arithmetic is left to the caller: the
value converts exactly from f64 (LongDouble::from_f64) and
rounds to the nearest f64 (LongDouble::to_f64). The bits travel
as they are, so a value received and sent again keeps its precision.
Implementations§
Source§impl LongDouble
impl LongDouble
Sourcepub const ZERO: LongDouble
pub const ZERO: LongDouble
Zero.
Sourcepub const fn from_bits(bits: u128) -> LongDouble
pub const fn from_bits(bits: u128) -> LongDouble
The value with these binary128 bits.
Sourcepub const fn from_f64(v: f64) -> LongDouble
pub const fn from_f64(v: f64) -> LongDouble
The value of v, exactly (binary128 holds every f64).
Sourcepub fn to_f64(self) -> f64
pub fn to_f64(self) -> f64
The nearest f64 (ties to even); out of range values become
infinities or zeros, a NaN stays a NaN.
Sourcepub fn is_sign_negative(self) -> bool
pub fn is_sign_negative(self) -> bool
Whether the sign bit is set (also for -0 and NaNs).
Sourcepub fn to_be_bytes(self) -> [u8; 16]
pub fn to_be_bytes(self) -> [u8; 16]
The bytes in big endian order, as CDR sends them in a big endian stream.
Sourcepub fn from_be_bytes(bytes: [u8; 16]) -> LongDouble
pub fn from_be_bytes(bytes: [u8; 16]) -> LongDouble
The value of these big endian bytes.
Trait Implementations§
Source§impl CdrDecode for LongDouble
impl CdrDecode for LongDouble
Source§impl CdrEncode for LongDouble
impl CdrEncode for LongDouble
Source§impl Clone for LongDouble
impl Clone for LongDouble
impl Copy for LongDouble
Source§impl Debug for LongDouble
impl Debug for LongDouble
Source§impl Default for LongDouble
impl Default for LongDouble
Source§impl Display for LongDouble
Shows the nearest f64.
impl Display for LongDouble
Shows the nearest f64.