Program Rust
Dec2flt_modelNumImpDec2fltLemireU32
This Rust is the input prepared for Aeneas. Modeling choices explains the adaptations from the production source.
171 }172 }173 174 impl Lemire for f32 {175 // Exact upstream formula results for `SIG_TOTAL_BITS = 24`.176 const MAX_EXPONENT_FAST_PATH: i64 = 10;177 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 17;178 179 fn pow10_fast_path(exponent: usize) -> Self {180 // Bit constructors preserve the exact table values and masked lookup,181 // while avoiding Aeneas's unsupported float-valued array constants.182 match exponent & 15 {183 0 => f32::from_bits(0x3F80_0000),184 1 => f32::from_bits(0x4120_0000),185 2 => f32::from_bits(0x42C8_0000),186 3 => f32::from_bits(0x447A_0000),187 4 => f32::from_bits(0x461C_4000),188 5 => f32::from_bits(0x47C3_5000),189 6 => f32::from_bits(0x4974_2400),190 7 => f32::from_bits(0x4B18_9680),191 8 => f32::from_bits(0x4CBE_BC20),192 9 => f32::from_bits(0x4E6E_6B28),193 10 => f32::from_bits(0x5015_02F9),194 _ => f32::from_bits(0),195 }196 }197 198 #[inline]199 // This is exactly the source `u64 as f32` conversion. The narrow opaque200 // boundary is required because Aeneas rejects the primitive cast itself;201 // its input guard and every caller remain transparent.202 #[charon::opaque]203 fn from_u64(v: u64) -> Self {204 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);205 v as _206 }207 }208 209 impl Lemire for f64 {210 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.Aeneas declaration
The Lean below was mechanically extracted by Aeneas from Rust.
@[reducible]
impl_def F32.Insts.Dec2flt_modelNumImpDec2fltLemireU32 : num.imp.dec2flt.Lemire
F32 Std.U32 := {
MAX_EXPONENT_FAST_PATH := ok
F32.Insts.Dec2flt_modelNumImpDec2fltLemireU32.MAX_EXPONENT_FAST_PATH
MIN_EXPONENT_FAST_PATH :=
num.imp.dec2flt.Lemire.MIN_EXPONENT_FAST_PATH.default
F32.Insts.Dec2flt_modelNumImpDec2fltLemireU32
MAX_EXPONENT_DISGUISED_FAST_PATH := ok
F32.Insts.Dec2flt_modelNumImpDec2fltLemireU32.MAX_EXPONENT_DISGUISED_FAST_PATH
MAX_MANTISSA_FAST_PATH :=
num.imp.dec2flt.Lemire.MAX_MANTISSA_FAST_PATH.default
F32.Insts.Dec2flt_modelNumImpDec2fltLemireU32
traitsFloatExtInst := F32.Insts.Dec2flt_modelNumImpTraitsFloatExtU32
pow10_fast_path :=
F32.Insts.Dec2flt_modelNumImpDec2fltLemireU32.pow10_fast_path
from_u64 := F32.Insts.Dec2flt_modelNumImpDec2fltLemireU32.from_u64
}Operations used here
Dec2flt_modelNumImpTraitsFloatExtU32 · Program Rust
pow10_fast_path · Program Rust
Source details
| Declaration | F32.Insts.Dec2flt_modelNumImpDec2fltLemireU32 |
|---|---|
| File | num/imp/../../dec2flt/mod.rs |
| Lines | 174:0–207:1 |
| Program version | Preparation 1 |