Program Rust
Dec2flt_modelNumImpTraitsFloatExtU16
This Rust is the input prepared for Aeneas. Modeling choices explains the adaptations from the production source.
215 }216 217 #[cfg(target_has_reliable_f16)]218 impl FloatExt for f16 {219 #[inline]220 fn from_u64_bits(v: u64) -> Self {221 Self::from_bits((v & 0xFFFF) as u16)222 }223 224 // Specializing the upstream default removes only unsupported associated-225 // integer operator resolution; these are the same bit operations with226 // `Self::Int = u16` and the same exponent-bias subtraction.227 fn integer_decode(self) -> (u64, i16, i8) {228 let bits = self.to_bits();229 let sign = if bits >> 15 == 0 { 1 } else { -1 };230 let mut exponent = ((bits & Self::EXPONENT_MASK) >> 10) as i16;231 let mantissa = if exponent == 0 {232 (bits & Self::MANTISSA_MASK) << 1233 } else {234 (bits & Self::MANTISSA_MASK) | (1_u16 << 10)235 };236 exponent -= 15 + 10;237 (mantissa as u64, exponent, sign)238 }239 }240 241 impl Float for f32 {242 type Int = u32;Aeneas declaration
The Lean below was mechanically extracted by Aeneas from Rust.
@[reducible]
def F16.Insts.Dec2flt_modelNumImpTraitsFloatExtU16 : num.imp.traits.FloatExt
F16 Std.U16 := {
FloatInst := F16.Insts.Dec2flt_modelNumImpTraitsFloatU16
from_u64_bits := F16.Insts.Dec2flt_modelNumImpTraitsFloatExtU16.from_u64_bits
integer_decode :=
F16.Insts.Dec2flt_modelNumImpTraitsFloatExtU16.integer_decode
}Operations used here
Source details
| Declaration | F16.Insts.Dec2flt_modelNumImpTraitsFloatExtU16 |
|---|---|
| File | num/imp/../../traits.rs |
| Lines | 218:0–239:1 |
| Program version | Preparation 1 |