Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace unsafe transmute to a cast #99

Merged
merged 1 commit into from Sep 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/lib.rs
Expand Up @@ -16,7 +16,6 @@ use core::fmt;
use core::hash::{Hash, Hasher};
use core::hint::unreachable_unchecked;
use core::iter::{Product, Sum};
use core::mem;
use core::num::FpCategory;
use core::ops::{
Add, AddAssign, Deref, DerefMut, Div, DivAssign, Mul, MulAssign, Neg, Rem, RemAssign, Sub,
Expand Down Expand Up @@ -1259,7 +1258,7 @@ fn raw_double_bits<F: Float>(f: &F) -> u64 {
return CANONICAL_ZERO_BITS;
}

let exp_u64 = unsafe { mem::transmute::<i16, u16>(exp) } as u64;
let exp_u64 = exp as u16 as u64;
let sign_u64 = if sign > 0 { 1u64 } else { 0u64 };
(man & MAN_MASK) | ((exp_u64 << 52) & EXP_MASK) | ((sign_u64 << 63) & SIGN_MASK)
}
Expand Down