Open the context
Choose the project folder and name the files or behavior involved.
Rotate an unsigned word left within a width from 1 through 64 bits. Check zero and full-width rotations with counts reduced modulo the width, rejecting negative counts and values that do not fit.
Choose the project folder and name the files or behavior involved.
Describe the input, expected output and boundaries that must stay intact.
Review the proposed edits and any commands before relying on their result.
Compare actual behavior with the expected result. If a check fails, investigate it before applying more changes.
def rotate_left(value, count, width):
if any(type(x) is not int for x in (value, count, width)):
raise ValueError("rotate.type")
if not 1 <= width <= 64 or not 0 <= value < (1 << width) or count < 0:
raise ValueError("rotate.range")
count %= width
mask = (1 << width) - 1
return ((value << count) | (value >> (width - count))) & maskThe example is a starting point for a real project, not a claim that generated code is already tested. Adjust paths, dependencies and expected behavior to match your application.