Program Rust
number_of_digits_decimal_left_shift_loop
This Rust is the input prepared for Aeneas. Modeling choices explains the adaptations from the production source.
438 let pow5_b = (0x7FF & x_b) as usize;439 let pow5 = &TABLE_POW5[pow5_a..];440 441 for (i, &p5) in pow5.iter().enumerate().take(pow5_b - pow5_a) {442 if i >= d.num_digits {443 return num_new_digits - 1;444 } else if d.digits[i] == p5 {445 continue;446 } else if d.digits[i] < p5 {447 return num_new_digits - 1;448 } else {449 return num_new_digits;450 }451 }452 453 num_new_digits454 }Aeneas declaration
The Lean below was mechanically extracted by Aeneas from Rust.
@[rust_loop]
def num.imp.dec2flt.decimal_seq.number_of_digits_decimal_left_shift_loop
(iter : core.iter.adapters.take.Take (core.iter.adapters.enumerate.Enumerate
(core.slice.iter.Iter Std.U8))) (d : num.imp.dec2flt.decimal_seq.DecimalSeq)
(num_new_digits : Std.Usize) :
Result Std.Usize
:= do
loop
(fun iter1 =>
num.imp.dec2flt.decimal_seq.number_of_digits_decimal_left_shift_loop.body
d num_new_digits iter1)
iterOther extracted objects at this span
num.imp.dec2flt.decimal_seq.number_of_digits_decimal_left_shift_loop.body
Source details
| Declaration | num.imp.dec2flt.decimal_seq.number_of_digits_decimal_left_shift_loop |
|---|---|
| File | num/imp/../../dec2flt/decimal_seq.rs |
| Lines | 441:4–454:1 |
| Program version | Revised program |