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

Shift then mask, rather than mask then shift #453

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/math/support/float_traits.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use core::{fmt, mem, ops};

use super::int_traits::{CastFrom, CastInto, Int, MinInt};
use super::int_traits::{CastFrom, Int, MinInt};

/// Trait for some basic operations on floats
#[allow(dead_code)]
Expand Down Expand Up @@ -108,7 +108,7 @@ pub trait Float:

/// Returns the exponent, not adjusting for bias, not accounting for subnormals or zero.
fn exp(self) -> i32 {
((self.to_bits() & Self::EXP_MASK) >> Self::SIG_BITS).cast()
(u32::cast_from(self.to_bits() >> Self::SIG_BITS) & Self::EXP_MAX).signed()
}

/// Extract the exponent and adjust it for bias, not accounting for subnormals or zero.
Expand Down