Rindle docs and package mapSkip to main content

is_exact_f64_integer

Function is_exact_f64_integer 

Source
pub fn is_exact_f64_integer(i: i64) -> bool
Expand description

True when widening i to f64 and narrowing it back preserves the exact integer. This deliberately accepts sparse, exactly representable integers above 2^53 (such as 2^54) while rejecting adjacent values that would lose precision.

The explicit upper-bound check handles i64::MAX: it rounds up to 2^63 as an f64, then Rust’s saturating float-to-integer cast would otherwise appear to round-trip back to i64::MAX. i64::MIN is exactly -2^63 and is accepted.