aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlexis Beingessner <a.beingessner@gmail.com>2017-11-15 15:31:22 -0500
committerAndrew Gallant <jamslam@gmail.com>2017-11-29 16:10:19 -0500
commit1b1f206f3fcd3026ae8d4e43c3e61b286520ef22 (patch)
tree3b57c399a9a44fa0178be04d0f3cae37192273bd /src
parent098064b8c94c42e86deb7689cb4648ca39f54b2c (diff)
downloadbyteorder-1b1f206f3fcd3026ae8d4e43c3e61b286520ef22.tar.gz
make int->float conversion a transmute
This is the mirror commit to https://github.com/rust-lang/rust/pull/46012
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs32
1 files changed, 2 insertions, 30 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 35c0069..6612a27 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -2185,40 +2185,12 @@ impl ByteOrder for LittleEndian {
#[inline]
fn safe_u32_bits_to_f32(u: u32) -> f32 {
- use core::f32::NAN;
-
- const EXP_MASK: u32 = 0x7F800000;
- const FRACT_MASK: u32 = 0x007FFFFF;
-
- if u & EXP_MASK == EXP_MASK && u & FRACT_MASK != 0 {
- // While IEEE 754-2008 specifies encodings for quiet NaNs and
- // signaling ones, certains MIPS and PA-RISC CPUs treat signaling
- // NaNs differently. Therefore, to be safe, we pass a known quiet
- // NaN if u is any kind of NaN. The check above only assumes
- // IEEE 754-1985 to be valid.
- NAN
- } else {
- unsafe { transmute(u) }
- }
+ unsafe { transmute(u) }
}
#[inline]
fn safe_u64_bits_to_f64(u: u64) -> f64 {
- use core::f64::NAN;
-
- const EXP_MASK: u64 = 0x7FF0000000000000;
- const FRACT_MASK: u64 = 0x000FFFFFFFFFFFFF;
-
- if u & EXP_MASK == EXP_MASK && u & FRACT_MASK != 0 {
- // While IEEE 754-2008 specifies encodings for quiet NaNs and
- // signaling ones, certains MIPS and PA-RISC CPUs treat signaling
- // NaNs differently. Therefore, to be safe, we pass a known quiet
- // NaN if u is any kind of NaN. The check above only assumes
- // IEEE 754-1985 to be valid.
- NAN
- } else {
- unsafe { transmute(u) }
- }
+ unsafe { transmute(u) }
}
#[cfg(test)]