Expand description
Safe numeric conversion helpers.
Only contains helpers for conversions where std’s From/TryFrom traits
don’t exist. For integer↔integer conversions, use From/TryFrom directly
(with ? — From<TryFromIntError> is implemented for RError).
Functions§
- f64_
to_ i32 f64 → i32— truncation toward zero, then check range.- f64_
to_ i64 f64 → i64— truncation toward zero (Ras.integer()semantics). Fails for NaN, ±Inf, or values outsidei64range.- f64_
to_ u32 f64 → u32— truncation toward zero, then check range.- f64_
to_ u64 f64 → u64— truncation toward zero, then check non-negative.- f64_
to_ usize f64 → usize— truncation toward zero, then check non-negative.- i64_
to_ f64 i64 → f64— always produces a valid f64, but may lose precision for|v| > 2^53. This matches R semantics whereas.double()on an integer always succeeds.- u64_
to_ f64 u64 → f64— always produces a valid f64, but may lose precision forv > 2^53.- usize_
to_ f64 usize → f64— always produces a valid f64, but may lose precision forv > 2^53.