Program Rust
body
This Rust is the input prepared for Aeneas. Modeling choices explains the adaptations from the production source.
91 }92 // We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].93 exp2 -= 1;94 while F::EXP_MIN > exp2 {95 let mut n = (F::EXP_MIN - exp2) as usize;96 if n > MAX_SHIFT {97 n = MAX_SHIFT;98 }99 d.right_shift(n);100 exp2 += n as i32;101 }102 if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {103 return fp_inf;104 }Aeneas declaration
The Lean below was mechanically extracted by Aeneas from Rust.
@[rust_loop_body]
def num.imp.dec2flt.slow.parse_long_mantissa_loop2.body
{F : Type} {Clause0_Int : Type} (traitsFloatInst : num.imp.traits.Float F
Clause0_Int) (d : num.imp.dec2flt.decimal_seq.DecimalSeq) (exp2 : Std.I32) :
Result (ControlFlow (num.imp.dec2flt.decimal_seq.DecimalSeq × Std.I32)
(num.imp.dec2flt.decimal_seq.DecimalSeq × Std.I32))
:= do
let i ← traitsFloatInst.EXP_MIN
if i > exp2
then
let i1 ← i - exp2
let n ← lift (IScalar.hcast .Usize i1)
let n1 ←
if n > num.imp.dec2flt.slow.parse_long_mantissa.MAX_SHIFT
then ok num.imp.dec2flt.slow.parse_long_mantissa.MAX_SHIFT
else ok n
let d1 ← num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift d n1
let i2 ← lift (UScalar.hcast .I32 n1)
let exp21 ← exp2 + i2
ok (cont (d1, exp21))
else ok (done (d, exp2))Operations used here
Other extracted objects at this span
Source details
| Declaration | num.imp.dec2flt.slow.parse_long_mantissa_loop2.body |
|---|---|
| File | num/imp/../../dec2flt/slow.rs |
| Lines | 94:4–101:5 |
| Program version | Preparation 2 |