Every programmer eventually encounters that moment of quiet confusion during a late-night debugging session: you cast a signed 8-bit -1 to hexadecimal, expecting something clean and human-readable, only for the debugger to spit back 0xFF . Widen it to a 32-bit register, and it suddenly balloons into 0xFFFFFFFF .
Where did the minus sign go? Why didn't it output -0x01 ? And why does running 0x20000000000001 through your standard JavaScript parser silently yield the wrong integer altogether?
Number base conversion is often treated as a trivial Computer Science 101 exercise—something solved with a simple parseInt(val, 16) or a textbook division-by-radix loop. But beneath high-level abstractions, radix shifts are inextricably linked to hardware registers, two’s complement mathematics, IEEE-754 rounding traps, and data-encoding strategies.
Here is what is actually happening under the hood when bits change their radix, and why understanding these low-level mechanics prevents catastrophic bugs in production.
1.…