Program Rust
pow10_fast_path
This Rust is the input prepared for Aeneas. Modeling choices explains the adaptations from the production source.
146 const MAX_EXPONENT_FAST_PATH: i64 = 4;147 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 7;148 149 fn pow10_fast_path(exponent: usize) -> Self {150 // Each integer is the exact IEEE encoding of the corresponding151 // upstream table literal; the masked lookup and fallback zeros are152 // unchanged. Aeneas cannot translate arrays containing float values.153 match exponent & 7 {154 0 => f16::from_bits(0x3C00),155 1 => f16::from_bits(0x4900),156 2 => f16::from_bits(0x5640),157 3 => f16::from_bits(0x63D0),158 4 => f16::from_bits(0x70E2),159 _ => f16::from_bits(0),160 }161 }162 163 #[inline]164 // This method is exactly the upstream primitive `u64 as f16` conversion.Aeneas declaration
The Lean below was mechanically extracted by Aeneas from Rust.
def F16.Insts.Dec2flt_modelNumImpDec2fltLemireU16.pow10_fast_path
(exponent : Std.Usize) : Result F16 := do
let i ← lift (exponent &&& 7#usize)
match i.val with
| 0 => core.f16.F16.from_bits 15360#u16
| 1 => core.f16.F16.from_bits 18688#u16
| 2 => core.f16.F16.from_bits 22080#u16
| 3 => core.f16.F16.from_bits 25552#u16
| 4 => core.f16.F16.from_bits 28898#u16
| _ => core.f16.F16.from_bits 0#u16Operations used here
Source details
| Declaration | F16.Insts.Dec2flt_modelNumImpDec2fltLemireU16.pow10_fast_path |
|---|---|
| File | num/imp/../../dec2flt/mod.rs |
| Lines | 149:4–161:5 |
| Program version | Preparation 1 |