replace some transmutes
This commit is contained in:
parent
cb4e9755b8
commit
26681724f3
2 changed files with 7 additions and 10 deletions
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -633,7 +633,7 @@ fn main() {
|
|||
if a.0.is_nan()
|
||||
|| b.0.is_nan()
|
||||
|| c.is_nan()
|
||||
|| c.abs() <= unsafe { mem::transmute(4503599627370495u64) }
|
||||
|| c.abs() <= f64::from_bits(4503599627370495u64)
|
||||
{
|
||||
None
|
||||
} else {
|
||||
|
|
@ -651,7 +651,7 @@ fn main() {
|
|||
if a.0.is_nan()
|
||||
|| b.0.is_nan()
|
||||
|| c.is_nan()
|
||||
|| c.abs() <= unsafe { mem::transmute(16777215u32) }
|
||||
|| c.abs() <= f32::from_bits(16777215u32)
|
||||
{
|
||||
None
|
||||
} else {
|
||||
|
|
@ -671,7 +671,7 @@ fn main() {
|
|||
if a.0.is_nan()
|
||||
|| b.0.is_nan()
|
||||
|| c.is_nan()
|
||||
|| c.abs() <= unsafe { mem::transmute(4503599627370495u64) }
|
||||
|| c.abs() <= f64::from_bits(4503599627370495u64)
|
||||
{
|
||||
None
|
||||
} else {
|
||||
|
|
@ -689,7 +689,7 @@ fn main() {
|
|||
if a.0.is_nan()
|
||||
|| b.0.is_nan()
|
||||
|| c.is_nan()
|
||||
|| c.abs() <= unsafe { mem::transmute(16777215u32) }
|
||||
|| c.abs() <= f32::from_bits(16777215u32)
|
||||
{
|
||||
None
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue