|
fn to_u64(self) -> Option<u64> { |
|
if self >= 0. && self <= ::core::u64::MAX as f64 { |
|
Some(self as u64) |
|
} else { |
|
None |
|
} |
|
} |
This function is wrong; to copy my comment from #958:
This is incorrect for 32-bit platforms. Check this out.
This isn't your fault; to_u64 for f64 makes the same mistake. Hmm, even the TryFrom in Rust 1.34 doesn't handle this conversion. I'm starting to hate this topic; seems simple but isn't.
rand/rand_distr/src/utils.rs
Lines 141 to 147 in bf8b5a9
This function is wrong; to copy my comment from #958: