|
@@ -1,4 +1,3 @@
|
|
|
-use core::mem;
|
|
|
use core::ops;
|
|
|
|
|
|
use super::int::Int;
|
|
@@ -85,8 +84,6 @@ pub trait Float:
|
|
|
fn is_subnormal(&self) -> bool;
|
|
|
}
|
|
|
|
|
|
-// FIXME: Some of this can be removed if RFC Issue #1424 is resolved
|
|
|
-// https://github.com/rust-lang/rfcs/issues/1424
|
|
|
macro_rules! float_impl {
|
|
|
($ty:ident, $ity:ident, $sity:ident, $bits:expr, $significand_bits:expr) => {
|
|
|
impl Float for $ty {
|
|
@@ -104,10 +101,10 @@ macro_rules! float_impl {
|
|
|
const EXPONENT_MASK: Self::Int = !(Self::SIGN_MASK | Self::SIGNIFICAND_MASK);
|
|
|
|
|
|
fn repr(self) -> Self::Int {
|
|
|
- unsafe { mem::transmute(self) }
|
|
|
+ self.to_bits()
|
|
|
}
|
|
|
fn signed_repr(self) -> Self::SignedInt {
|
|
|
- unsafe { mem::transmute(self) }
|
|
|
+ self.to_bits() as Self::SignedInt
|
|
|
}
|
|
|
fn eq_repr(self, rhs: Self) -> bool {
|
|
|
if self.is_nan() && rhs.is_nan() {
|
|
@@ -117,7 +114,7 @@ macro_rules! float_impl {
|
|
|
}
|
|
|
}
|
|
|
fn from_repr(a: Self::Int) -> Self {
|
|
|
- unsafe { mem::transmute(a) }
|
|
|
+ Self::from_bits(a)
|
|
|
}
|
|
|
fn from_parts(sign: bool, exponent: Self::Int, significand: Self::Int) -> Self {
|
|
|
Self::from_repr(
|