Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit d19c70b

Browse files
WalterBrightdlang-bot
authored andcommitted
core.bitop: use recognized pattern for rotates
1 parent 0d3d199 commit d19c70b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/core/bitop.d

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -951,28 +951,28 @@ pure T rol(T)(const T value, const uint count)
951951
if (__traits(isIntegral, T) && __traits(isUnsigned, T))
952952
{
953953
assert(count < 8 * T.sizeof);
954-
return cast(T) ((value << count) | (value >> (-count & (T.sizeof * 8 - 1))));
954+
return cast(T) ((value << count) | (value >> (T.sizeof * 8 - count)));
955955
}
956956
/// ditto
957957
pure T ror(T)(const T value, const uint count)
958958
if (__traits(isIntegral, T) && __traits(isUnsigned, T))
959959
{
960960
assert(count < 8 * T.sizeof);
961-
return cast(T) ((value >> count) | (value << (-count & (T.sizeof * 8 - 1))));
961+
return cast(T) ((value >> count) | (value << (T.sizeof * 8 - count)));
962962
}
963963
/// ditto
964964
pure T rol(uint count, T)(const T value)
965965
if (__traits(isIntegral, T) && __traits(isUnsigned, T))
966966
{
967967
static assert(count < 8 * T.sizeof);
968-
return cast(T) ((value << count) | (value >> (-count & (T.sizeof * 8 - 1))));
968+
return cast(T) ((value << count) | (value >> (T.sizeof * 8 - count)));
969969
}
970970
/// ditto
971971
pure T ror(uint count, T)(const T value)
972972
if (__traits(isIntegral, T) && __traits(isUnsigned, T))
973973
{
974974
static assert(count < 8 * T.sizeof);
975-
return cast(T) ((value >> count) | (value << (-count & (T.sizeof * 8 - 1))));
975+
return cast(T) ((value >> count) | (value << (T.sizeof * 8 - count)));
976976
}
977977

978978
///

0 commit comments

Comments
 (0)