Open the context
Choose the project folder and name the files or behavior involved.
Compare two unsigned 32-bit serial numbers using the shorter modular difference. Test wrap neighbors and equality, reject Boolean inputs and the ambiguous half-range difference without assuming a global total order.
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 serial_order(a, b):
if any(type(x) is not int or not 0 <= x < 2**32 for x in (a, b)):
raise ValueError("serial.value")
difference = (a-b) & 0xffffffff
if difference == 2**31:
raise ValueError("serial.ambiguous")
return 0 if difference == 0 else 1 if difference < 2**31 else -1
The 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.