Source context

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

Float · Program Rust

DecimalSeq · Program Rust

right_shift · Program Rust

MAX_SHIFT · Program Rust

Other extracted objects at this span

num.imp.dec2flt.slow.parse_long_mantissa_loop2

Source details
Declarationnum.imp.dec2flt.slow.parse_long_mantissa_loop2.body
Filenum/imp/../../dec2flt/slow.rs
Lines94:4–101:5
Program versionPreparation 2