1// FLOAT TYPE 2 3#![doc(hidden)] 4 5use crate::num::Float; 6 7/// Extended precision floating-point type. 8/// 9/// Private implementation, exposed only for testing purposes. 10#[derive(Clone, Copy, Debug, PartialEq, Eq)] 11pub struct ExtendedFloat { 12 /// Mantissa for the extended-precision float. 13 pub mant: u64, 14 /// Binary exponent for the extended-precision float. 15 pub exp: i32, 16} 17 18/// Converts an `ExtendedFloat` to the closest machine float type. 19#[inline(always)] 20pub fn extended_to_float<F: Float>(x: ExtendedFloat) -> F { 21 let mut word = x.mant; 22 word |= (x.exp as u64) << F::MANTISSA_SIZE; 23 F::from_bits(word) 24} 25