Program Rust
left_shift_loop0
This Rust is the input prepared for Aeneas. Modeling choices explains the adaptations from the production source.
135 let mut write_index = self.num_digits + num_new_digits;136 let mut n = 0_u64;137 138 while read_index != 0 {139 read_index -= 1;140 write_index -= 1;141 n += (self.digits[read_index] as u64) << shift;142 let quotient = n / 10;143 let remainder = n - (10 * quotient);144 if write_index < Self::MAX_DIGITS {145 self.digits[write_index] = remainder as u8;146 } else if remainder > 0 {147 self.truncated = true;148 }149 n = quotient;150 }151 152 while n > 0 {153 write_index -= 1;Aeneas declaration
The Lean below was mechanically extracted by Aeneas from Rust.
@[rust_loop]
def num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift_loop0
(b : Bool) (a : Array Std.U8 768#usize) (shift : Std.Usize)
(read_index : Std.Usize) (write_index : Std.Usize) (n : Std.U64) :
Result (Bool × (Array Std.U8 768#usize) × Std.Usize × Std.U64)
:= do
loop
(fun (b1, a1, read_index1, write_index1, n1) =>
num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift_loop0.body shift b1 a1
read_index1 write_index1 n1)
(b, a, read_index, write_index, n)Operations used here
Other extracted objects at this span
num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift_loop0.body
Source details
| Declaration | num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift_loop0 |
|---|---|
| File | num/imp/../../dec2flt/decimal_seq.rs |
| Lines | 138:8–150:9 |
| Program version | Original program |