about summary refs log tree commit diff
path: root/src/libcore/num
diff options
context:
space:
mode:
authorSamuel Neves <sneves@dei.uc.pt>2014-07-02 04:58:23 +0100
committerSamuel Neves <sneves@dei.uc.pt>2014-07-02 23:45:27 +0100
commitc0248c0839cfdf5b7030f4191ea7aed0981b9e4e (patch)
tree2e3e0ae4add8712ab32732caa46a4b4b812c43b2 /src/libcore/num
parent380657557cb3793d39dfc0d2321fc946cb3496f5 (diff)
downloadrust-c0248c0839cfdf5b7030f4191ea7aed0981b9e4e.tar.gz
rust-c0248c0839cfdf5b7030f4191ea7aed0981b9e4e.zip
Fix rotate_{left, right} for multiple of bitsize rotation amounts
Add additional rotation tests
Diffstat (limited to 'src/libcore/num')
-rw-r--r--src/libcore/num/mod.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs
index b32e4167da1..1fae362471d 100644
--- a/src/libcore/num/mod.rs
+++ b/src/libcore/num/mod.rs
@@ -586,14 +586,14 @@ macro_rules! int_impl {
             fn rotate_left(self, n: uint) -> $T {
                 // Protect against undefined behaviour for over-long bit shifts
                 let n = n % $BITS;
-                (self << n) | (self >> ($BITS - n))
+                (self << n) | (self >> (($BITS - n) % $BITS))
             }
 
             #[inline]
             fn rotate_right(self, n: uint) -> $T {
                 // Protect against undefined behaviour for over-long bit shifts
                 let n = n % $BITS;
-                (self >> n) | (self << ($BITS - n))
+                (self >> n) | (self << (($BITS - n) % $BITS))
             }
 
             #[inline]