[−][src]Struct ibmfloat::F64
A 64-bit IBM floating point number.
This type supports the conversions:
- Transmuting to/from a
u64
viafrom_bits()
,to_bits()
- Transmuting to/from a big-endian
[u8; 8]
viafrom_be_bytes()
/to_be_bytes()
- Lossily converting to an
f32
viaFrom
/Into
- Lossily converting to an
f64
viaFrom
/Into
IBM F64
floats have slightly more precision than IEEE-754 f64
floats, but they cover a
slightly smaller domain. Most conversions will require rounding, but there is no risk of
overflow or underflow.
let foreign_float = ibmfloat::F64::from_bits(0x4110000000000000); let native_float = f64::from(foreign_float); assert_eq!(native_float, 1.0f64); let native_float: f64 = foreign_float.into(); assert_eq!(native_float, 1.0f64);
Methods
impl F64
[src]
pub fn from_bits(value: u64) -> Self
[src]
Transmute a native-endian u64
into an F64
.
let foreign_float = ibmfloat::F64::from_bits(0x4110000000000000); let native_float = f64::from(foreign_float); assert_eq!(native_float, 1.0f64);
pub fn to_bits(self) -> u64
[src]
Transmute this F64
to a native-endian u64
.
let foreign_float = ibmfloat::F64::from_bits(0x4110000000000000); assert_eq!(foreign_float.to_bits(), 0x4110000000000000);
pub fn from_be_bytes(bytes: [u8; 8]) -> Self
[src]
Create a floating point value from its representation as a byte array in big endian.
let foreign_float = ibmfloat::F64::from_be_bytes([0x41, 0x10, 0, 0, 0, 0, 0, 0]); assert_eq!(foreign_float.to_bits(), 0x4110000000000000); let native_float = f64::from(foreign_float); assert_eq!(native_float, 1.0f64);
pub fn to_be_bytes(self) -> [u8; 8]
[src]
Return the memory representation of this floating point number as a byte array in big-endian (network) byte order.
let foreign_float = ibmfloat::F64::from_bits(0x4110000000000000); assert_eq!(foreign_float.to_be_bytes(), [0x41, 0x10, 0, 0, 0, 0, 0, 0]);
Trait Implementations
impl Clone for F64
[src]
impl Copy for F64
[src]
impl Debug for F64
[src]
impl From<F64> for f32
[src]
impl From<F64> for f64
[src]
impl PartialEq<F64> for F64
[src]
impl PartialOrd<F64> for F64
[src]
Auto Trait Implementations
impl RefUnwindSafe for F64
impl Send for F64
impl Sync for F64
impl Unpin for F64
impl UnwindSafe for F64
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,