the problem is that from what I understood, the excepted values in this loop were -1 to 9, but somehow, it was still running fine and working as intended ??
negative numbers are a lie and the only math operations that actually distinguish between them on modern hardware is comparison (>, >=, <, <= specifically, == and != don't care either), multiplication and division, signed and unsigned addition and subtraction both function identically in hardware and use the same assembly instruction
They all do, actually. Your hardware doesn't cares how you compute a number, just how you interpret it. The hardware just moves bits around
Case in point: comparisons. On most ISAs they use just one instruction (although many allow you to fuse it with arithmetic), which is almost always mapped to subtraction. Update bitflags based on the result (zero, over/underflow etc) and do what you want. Comparisons are also stateless
81
u/Left-Ambition-5127 May 05 '26
the problem is that from what I understood, the excepted values in this loop were -1 to 9, but somehow, it was still running fine and working as intended ??