Source context

Program Rust

can_use_fast_path

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

39 impl Decimal {40     /// Detect if the float can be accurately reconstructed from native floats.41     #[inline]42     fn can_use_fast_path<F: Lemire>(&self) -> bool {43         F::MIN_EXPONENT_FAST_PATH <= self.exponent44             && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH45             && self.mantissa <= F::MAX_MANTISSA_FAST_PATH46             && !self.many_digits47     }48 49     /// Try turning the decimal into an exact float representation, using machine-sized integers50     /// and floats.

Aeneas declaration

The Lean below was mechanically extracted by Aeneas from Rust.

def num.imp.dec2flt.decimal.Decimal.can_use_fast_path
  {F : Type} {Clause0_Clause0_Clause0_Int : Type} (LemireInst :
  num.imp.dec2flt.Lemire F Clause0_Clause0_Clause0_Int)
  (self : num.imp.dec2flt.decimal.Decimal) :
  Result Bool
  := do
  let i ← LemireInst.MIN_EXPONENT_FAST_PATH
  if i <= self.exponent
  then
    let i1 ← LemireInst.MAX_EXPONENT_DISGUISED_FAST_PATH
    if self.exponent <= i1
    then
      let i2 ← LemireInst.MAX_MANTISSA_FAST_PATH
      if self.mantissa <= i2
      then ok (¬ self.many_digits)
      else ok false
    else ok false
  else ok false
Operations used here

Decimal · Program Rust

Lemire · Program Rust

Source details
Declarationnum.imp.dec2flt.decimal.Decimal.can_use_fast_path
Filenum/imp/../../dec2flt/decimal.rs
Lines42:4–47:5
Program versionOriginal program