Source context

Program Rust

is_8digits

This Rust is the input prepared for Aeneas. Modeling choices explains the adaptations from the production source.

37 /// digits.38 ///39 /// This does not care about the order in which the bytes were loaded.40 pub(crate) fn is_8digits(v: u64) -> bool {41     let a = v.wrapping_add(0x4646_4646_4646_4646);42     let b = v.wrapping_sub(0x3030_3030_3030_3030);43     (a | b) & 0x8080_8080_8080_8080 == 044 }45 46 /// A custom 64-bit floating point type, representing `m * 2^p`.47 /// p is biased, so it be directly shifted into the exponent bits.

Aeneas declaration

The Lean below was mechanically extracted by Aeneas from Rust.

def num.imp.dec2flt.common.is_8digits (v : Std.U64) : Result Bool := do
  let a ← lift (core.num.U64.wrapping_add v 5063812098665367110#u64)
  let b ← lift (core.num.U64.wrapping_sub v 3472328296227680304#u64)
  let i ← lift (a ||| b)
  let i1 ← lift (i &&& 9259542123273814144#u64)
  ok (i1 = 0#u64)
Source details
Declarationnum.imp.dec2flt.common.is_8digits
Filenum/imp/../../dec2flt/common.rs
Lines40:0–44:1
Program versionOriginal program