Remove f32::to_bits and f64::to_bits to support rust 1.26.0

This commit is contained in:
David Tolnay
2018-08-04 19:04:16 -07:00
parent 5c26a5ada4
commit bbafec70ae
3 changed files with 6 additions and 6 deletions
+1 -1
View File
@@ -429,7 +429,7 @@ unsafe fn to_chars(v: FloatingDecimal64, sign: bool, result: *mut u8) -> usize {
#[cfg_attr(feature = "no-panic", no_panic)]
pub unsafe fn d2s_buffered_n(f: f64, result: *mut u8) -> usize {
// Step 1: Decode the floating-point number, and unify normalized and subnormal cases.
let bits = f.to_bits().to_le();
let bits = mem::transmute::<f64, u64>(f).to_le();
// Decode bits into sign, mantissa, and exponent.
let ieee_sign = ((bits >> (DOUBLE_MANTISSA_BITS + DOUBLE_EXPONENT_BITS)) & 1) != 0;
+2 -2
View File
@@ -18,7 +18,7 @@
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.
use core::ptr;
use core::{mem, ptr};
use common::*;
use digit_table::*;
@@ -431,7 +431,7 @@ unsafe fn to_chars(v: FloatingDecimal32, sign: bool, result: *mut u8) -> usize {
#[cfg_attr(feature = "no-panic", no_panic)]
pub unsafe fn f2s_buffered_n(f: f32, result: *mut u8) -> usize {
// Step 1: Decode the floating-point number, and unify normalized and subnormal cases.
let bits = f.to_bits().to_le();
let bits = mem::transmute::<f32, u32>(f).to_le();
// Decode bits into sign, mantissa, and exponent.
let sign = ((bits >> (FLOAT_MANTISSA_BITS + FLOAT_EXPONENT_BITS)) & 1) != 0;
+3 -3
View File
@@ -1,7 +1,7 @@
mod exponent;
mod mantissa;
use core::ptr;
use core::{mem, ptr};
use self::exponent::*;
use self::mantissa::*;
@@ -14,7 +14,7 @@ use no_panic::no_panic;
#[must_use]
#[cfg_attr(feature = "no-panic", no_panic)]
pub(crate) unsafe fn d2s_buffered_n(f: f64, result: *mut u8) -> usize {
let bits = f.to_bits().to_le();
let bits = mem::transmute::<f64, u64>(f).to_le();
let sign = ((bits >> (DOUBLE_MANTISSA_BITS + DOUBLE_EXPONENT_BITS)) & 1) != 0;
let ieee_mantissa = bits & ((1u64 << DOUBLE_MANTISSA_BITS) - 1);
let ieee_exponent =
@@ -86,7 +86,7 @@ pub(crate) unsafe fn d2s_buffered_n(f: f64, result: *mut u8) -> usize {
#[must_use]
#[cfg_attr(feature = "no-panic", no_panic)]
pub(crate) unsafe fn f2s_buffered_n(f: f32, result: *mut u8) -> usize {
let bits = f.to_bits().to_le();
let bits = mem::transmute::<f32, u32>(f).to_le();
let sign = ((bits >> (FLOAT_MANTISSA_BITS + FLOAT_EXPONENT_BITS)) & 1) != 0;
let ieee_mantissa = bits & ((1u32 << FLOAT_MANTISSA_BITS) - 1);
let ieee_exponent =