shifts are still garbage

This commit is contained in:
Christoph J. Scherr 2023-04-25 12:04:16 +02:00
parent f12013a3b7
commit 4690fe53da
Signed by: PlexSheep
GPG Key ID: 25B4ACF7D88186CC
1 changed files with 3 additions and 3 deletions

View File

@ -23,16 +23,16 @@ CHAR_BIT = 8
VALUE_SIZE = 4
"""
The rotations are tested agains a c implementation and seem to work fine.
The rotations are tested agains a c implementation and are still garbage. FIXME
"""
def rotl(value: int, count: int) -> int:
mask: int = CHAR_BIT * VALUE_SIZE - 1;
count &= mask;
count = count & mask
return (value << count) | (value >> (-count & mask));
def rotr(value: int, count: int) -> int:
mask: int = CHAR_BIT * VALUE_SIZE - 1;
count &= mask;
count = count & mask
return (value >> count) | (value << (-count & mask));
"""