Source context

Program Rust

Lemire

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

112 ///113 /// Not intended for use outside of the `dec2flt` module.114 #[doc(hidden)]115 pub trait Lemire: FloatExt {116     /// Maximum exponent for a fast path case, or `⌊(SIG_BITS+1)/log2(5)⌋`117     // assuming FLT_EVAL_METHOD = 0118     const MAX_EXPONENT_FAST_PATH: i64;119 120     /// Minimum exponent for a fast path case, or `-⌊(SIG_BITS+1)/log2(5)⌋`121     const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;122 123     /// Maximum exponent that can be represented for a disguised-fast path case.124     /// This is `MAX_EXPONENT_FAST_PATH + ⌊(SIG_BITS+1)/log2(10)⌋`125     const MAX_EXPONENT_DISGUISED_FAST_PATH: i64;126 127     /// Maximum mantissa for the fast-path (`1 << 53` for f64).128     const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;129 130     /// Gets a small power-of-ten for fast-path multiplication.131     fn pow10_fast_path(exponent: usize) -> Self;132 133     /// Converts integer into float through an as cast.134     /// This is only called in the fast-path algorithm, and therefore135     /// will not lose precision, since the value will always have136     /// only if the value is <= Self::MAX_MANTISSA_FAST_PATH.137     fn from_u64(v: u64) -> Self;138 }139 140 #[cfg(target_has_reliable_f16)]141 // The f16 Lemire instance is outside the exclusively f64 scope. Disabling it

Aeneas declaration

The Lean below was mechanically extracted by Aeneas from Rust.

structure num.imp.dec2flt.Lemire (Self : Type) (Self_Clause0_Clause0_Int :
  Type) where
  MAX_EXPONENT_FAST_PATH : Result Std.I64
  MIN_EXPONENT_FAST_PATH : Result Std.I64
  MAX_EXPONENT_DISGUISED_FAST_PATH : Result Std.I64
  MAX_MANTISSA_FAST_PATH : Result Std.U64
  traitsFloatExtInst : num.imp.traits.FloatExt Self Self_Clause0_Clause0_Int
  pow10_fast_path : Std.Usize → Result Self
  from_u64 : Std.U64 → Result Self
Operations used here

FloatExt · Program Rust

Source details
Declarationnum.imp.dec2flt.Lemire
Filenum/imp/../../dec2flt/mod.rs
Lines115:0–138:1
Program versionRevised program