Skip to content

Commit 513ffd4

Browse files
author
Dániel Buga
committed
Fix remaining compiler sadness
1 parent 53b79bd commit 513ffd4

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/register/fpscr.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@ pub struct Fpscr {
1010
/// Rounding mode
1111
#[derive(Clone, Copy, Debug)]
1212
pub enum RMode {
13+
/// Round to Nearest (RN) mode. This is the reset value.
1314
Nearest,
15+
/// Round towards Plus Infinity (RP) mode.
1416
PlusInfinity,
17+
/// Round towards Minus Infinity (RM) mode.
1518
MinusInfinity,
19+
/// Round towards Zero (RZ) mode.
1620
Zero,
1721
}
1822

@@ -68,11 +72,11 @@ impl Fpscr {
6872
/// Read the Rounding Mode control field
6973
#[inline]
7074
pub fn rmode(self) -> RMode {
71-
match self.bits & (3 << 22) {
72-
0 << 22 => RMode::Nearest,
73-
1 << 22 => RMode::PlusInfinity,
74-
2 << 22 => RMode::MinusInfinity,
75-
3 << 22 => RMode::Zero,
75+
match (self.bits & (3 << 22)) >> 22 {
76+
0 => RMode::Nearest,
77+
1 => RMode::PlusInfinity,
78+
2 => RMode::MinusInfinity,
79+
_ => RMode::Zero,
7680
}
7781
}
7882

0 commit comments

Comments
 (0)