Program Rust
parse_long_mantissa_loop0
This Rust is the input prepared for Aeneas. Modeling choices explains the adaptations from the production source.
48 let mut exp2 = 0_i32;49 let mut loop_result = None;50 // Shift right toward (1/2 ... 1].51 while d.decimal_point > 0 && loop_result.is_none() {52 let n = d.decimal_point as usize;53 let shift = get_shift(n);54 d.right_shift(shift);55 if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {56 // The source returns `fp_zero` at this exact point. Storing that57 // result and terminating the loop performs no later loop update;58 // the return below is therefore behavior-identical and avoids an59 // Aeneas restriction on returns from nested loop translation.60 loop_result = Some(fp_zero);61 } else {62 exp2 += shift as i32;63 }64 }65 if let Some(result) = loop_result {66 return result;67 }Aeneas declaration
The Lean below was mechanically extracted by Aeneas from Rust.
@[rust_loop]
def num.imp.dec2flt.slow.parse_long_mantissa_loop0
{F : Type} {Clause0_Int : Type} (traitsFloatInst : num.imp.traits.Float F
Clause0_Int) (fp_zero : num.imp.dec2flt.common.BiasedFp) (i : Std.Usize)
(i1 : Std.I32) (b : Bool) (a : Array Std.U8 768#usize) (exp2 : Std.I32)
(loop_result : Option num.imp.dec2flt.common.BiasedFp) :
Result (Std.Usize × Std.I32 × Bool × (Array Std.U8 768#usize) × Std.I32
× (Option num.imp.dec2flt.common.BiasedFp))
:= do
loop
(fun (i2, i3, b1, a1, exp21, loop_result1) =>
num.imp.dec2flt.slow.parse_long_mantissa_loop0.body traitsFloatInst
fp_zero i2 i3 b1 a1 exp21 loop_result1)
(i, i1, b, a, exp2, loop_result)Other extracted objects at this span
Source details
| Declaration | num.imp.dec2flt.slow.parse_long_mantissa_loop0 |
|---|---|
| File | num/imp/../../dec2flt/slow.rs |
| Lines | 51:4–64:5 |
| Program version | Preparation 2 |