From 49dc1a5e06a04c4cb6bd136f7dedb85719646e10 Mon Sep 17 00:00:00 2001 From: Fenrir Date: Thu, 15 Feb 2018 21:15:14 -0700 Subject: Updates for Rust 1.24 --- ctr-std/src/f32.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'ctr-std/src/f32.rs') diff --git a/ctr-std/src/f32.rs b/ctr-std/src/f32.rs index 5e5695f..a760922 100644 --- a/ctr-std/src/f32.rs +++ b/ctr-std/src/f32.rs @@ -1015,7 +1015,7 @@ impl f32 { #[stable(feature = "float_bits_conv", since = "1.20.0")] #[inline] pub fn to_bits(self) -> u32 { - unsafe { ::mem::transmute(self) } + num::Float::to_bits(self) } /// Raw transmutation from `u32`. @@ -1023,7 +1023,7 @@ impl f32 { /// This is currently identical to `transmute::(v)` on all platforms. /// It turns out this is incredibly portable, for two reasons: /// - /// * Floats and Ints have the same endianess on all supported platforms. + /// * Floats and Ints have the same endianness on all supported platforms. /// * IEEE-754 very precisely specifies the bit layout of floats. /// /// However there is one caveat: prior to the 2008 version of IEEE-754, how @@ -1059,8 +1059,7 @@ impl f32 { #[stable(feature = "float_bits_conv", since = "1.20.0")] #[inline] pub fn from_bits(v: u32) -> Self { - // It turns out the safety issues with sNaN were overblown! Hooray! - unsafe { ::mem::transmute(v) } + num::Float::from_bits(v) } } @@ -1532,6 +1531,7 @@ mod tests { assert!(nan.to_degrees().is_nan()); assert_eq!(inf.to_degrees(), inf); assert_eq!(neg_inf.to_degrees(), neg_inf); + assert_eq!(1_f32.to_degrees(), 57.2957795130823208767981548141051703); } #[test] -- cgit v1.2.3