diff options
| author | Samuel Neves <sneves@dei.uc.pt> | 2014-07-02 04:58:23 +0100 |
|---|---|---|
| committer | Samuel Neves <sneves@dei.uc.pt> | 2014-07-02 23:45:27 +0100 |
| commit | c0248c0839cfdf5b7030f4191ea7aed0981b9e4e (patch) | |
| tree | 2e3e0ae4add8712ab32732caa46a4b4b812c43b2 /src/libcore/num | |
| parent | 380657557cb3793d39dfc0d2321fc946cb3496f5 (diff) | |
| download | rust-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.rs | 4 |
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] |
