Program Rust
parse_decimal_exponent
This Rust is the input prepared for Aeneas. Modeling choices explains the adaptations from the production source.
266 // Equivalent to the source exponent `parse_digits` closure. Bytes after the267 // first nondigit were ignored by the caller, so only the accumulated value is268 // returned; the 0x10000 guard and wrapping digit classification are identical.269 fn parse_decimal_exponent(s: &[u8]) -> i32 {270 let mut exp_num = 0;271 let mut count = 0;272 while count < s.len() && s[count].wrapping_sub(b'0') < 10 {273 let digit = s[count].wrapping_sub(b'0');274 if exp_num < 0x10000 {275 exp_num = 10 * exp_num + digit as i32;276 }277 count += 1;278 }279 exp_num280 }281 282 /// Parse a big integer representation of the float as a decimal.283 pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {Aeneas declaration
The Lean below was mechanically extracted by Aeneas from Rust.
@[reducible]
def num.imp.dec2flt.decimal_seq.parse_decimal_exponent
(s : Slice Std.U8) : Result Std.I32 := do
num.imp.dec2flt.decimal_seq.parse_decimal_exponent_loop s 0#i32 0#usizeOperations used here
Source details
| Declaration | num.imp.dec2flt.decimal_seq.parse_decimal_exponent |
|---|---|
| File | num/imp/../../dec2flt/decimal_seq.rs |
| Lines | 269:0–280:1 |
| Program version | Original program |