Program Rust
body
This Rust is the input prepared for Aeneas. Modeling choices explains the adaptations from the production source.
149 n = quotient;150 }151 152 while n > 0 {153 write_index -= 1;154 let quotient = n / 10;155 let remainder = n - (10 * quotient);156 if write_index < Self::MAX_DIGITS {157 self.digits[write_index] = remainder as u8;158 } else if remainder > 0 {159 self.truncated = true;160 }161 n = quotient;162 }163 164 self.num_digits += num_new_digits;165 Aeneas declaration
The Lean below was mechanically extracted by Aeneas from Rust.
@[rust_loop_body]
def num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift_loop1.body
(b : Bool) (a : Array Std.U8 768#usize) (write_index : Std.Usize)
(n : Std.U64) :
Result (ControlFlow (Bool × (Array Std.U8 768#usize) × Std.Usize ×
Std.U64) (Bool × (Array Std.U8 768#usize)))
:= do
if n > 0#u64
then
let write_index1 ← write_index - 1#usize
let quotient ← n / 10#u64
let i ← 10#u64 * quotient
let remainder ← n - i
if write_index1 < num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then
let i1 ← lift (UScalar.cast .U8 remainder)
let a1 ← Array.update a write_index1 i1
ok (cont (b, a1, write_index1, quotient))
else
if remainder > 0#u64
then ok (cont (true, a, write_index1, quotient))
else ok (cont (b, a, write_index1, quotient))
else ok (done (b, a))Operations used here
Other extracted objects at this span
Source details
| Declaration | num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift_loop1.body |
|---|---|
| File | num/imp/../../dec2flt/decimal_seq.rs |
| Lines | 152:8–162:9 |
| Program version | Original program |