Program Rust
pow10_fast_path
This Rust is the input prepared for Aeneas. Modeling choices explains the adaptations from the production source.
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 opaqueAeneas declaration
The Lean below was mechanically extracted by Aeneas from Rust.
def F32.Insts.Dec2flt_modelNumImpDec2fltLemireU32.pow10_fast_path
(exponent : Std.Usize) : Result F32 := do
let i ← lift (exponent &&& 15#usize)
match i.val with
| 0 => core.f32.F32.from_bits 1065353216#u32
| 1 => core.f32.F32.from_bits 1092616192#u32
| 2 => core.f32.F32.from_bits 1120403456#u32
| 3 => core.f32.F32.from_bits 1148846080#u32
| 4 => core.f32.F32.from_bits 1176256512#u32
| 5 => core.f32.F32.from_bits 1203982336#u32
| 6 => core.f32.F32.from_bits 1232348160#u32
| 7 => core.f32.F32.from_bits 1259902592#u32
| 8 => core.f32.F32.from_bits 1287568416#u32
| 9 => core.f32.F32.from_bits 1315859240#u32
| 10 => core.f32.F32.from_bits 1343554297#u32
| _ => core.f32.F32.from_bits 0#u32Operations used here
Source details
| Declaration | F32.Insts.Dec2flt_modelNumImpDec2fltLemireU32.pow10_fast_path |
|---|---|
| File | num/imp/../../dec2flt/mod.rs |
| Lines | 179:4–196:5 |
| Program version | Preparation 1 |