See any integer as two's complement bits at four widths, with both the signed and unsigned reading of those bits and the byte order.
-1 — read as decimal
Fits a signed 8-bit integer; the narrowest type that holds it.
Two’s complement
1111 1111FFFF-1 is negative, so as an unsigned 8-bit value these same bits read as 255. A negative length or index assigned to an unsigned type becomes an enormous positive one.
Two’s complement
1111 1111 1111 1111FFFFFFFF-1 is negative, so as an unsigned 16-bit value these same bits read as 65535. A negative length or index assigned to an unsigned type becomes an enormous positive one.
Two’s complement
1111 1111 1111 1111 1111 1111 1111 1111FFFFFFFFFFFFFFFF-1 is negative, so as an unsigned 32-bit value these same bits read as 4294967295. A negative length or index assigned to an unsigned type becomes an enormous positive one.
Two’s complement
1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF-1 is negative, so as an unsigned 64-bit value these same bits read as 18446744073709551615. A negative length or index assigned to an unsigned type becomes an enormous positive one.
A negative value has no bit pattern of its own — two's complement is a convention for reading one. The leading 1 marks it negative only because the type says the value is signed.
JavaScript's own bitwise operators convert to a signed 32-bit integer before acting, so `1 << 32` is 1 and `0xFFFFFFFF | 0` is −1. The patterns here are computed with BigInt instead, so the 64-bit row is correct rather than truncated.
Integer Representation Inspector runs entirely on your device — every value is computed in the page with exact big-integer arithmetic.
You’re on the Free plan. Compare plans
One value, four widths, and the point is not the conversion. It is that the same bits mean different numbers depending only on how the variable was declared: `0xFF` is 255 or −1, and nothing in the bits says which. Every width shows the pattern, both readings and the byte order side by side, because that is where the lesson lives.
Two's complement is a convention for reading a pattern, not a property of the number. A negative value has no bit pattern of its own — the leading 1 marks it negative only because the type says the value is signed. That is why a signed overflow and a negative number are indistinguishable once the type information is gone, and why the tool shows both readings of every pattern rather than picking one.
Overflow is reported with what the value becomes, not just that it happened. 200 in a signed 8-bit type reads as −56; −1 in an unsigned type reads as 255. A negative length assigned to an unsigned variable becoming an enormous positive one is a whole category of bug, and seeing the two numbers next to each other is the shortest explanation of it.
Byte order is shown both ways. The same four bytes spell two different numbers on two different machines, which is why `0x12345678` reads as `12 34 56 78` in a file written big-endian and `78 56 34 12` on the x86 or ARM machine that wrote it little-endian.
Every value is computed with exact big-integer arithmetic. JavaScript's own bitwise operators coerce to a signed 32-bit integer first, so `1 << 32` is 1 and `0xFFFFFFFF | 0` is −1 — using them here would reproduce the exact bug this tool exists to explain, and the 64-bit row would be silently wrong.
Because in a signed 8-bit type it does. 200 is above the signed maximum of 127, so the pattern `11001000` reads as −56 when the type is signed and 200 when it is unsigned. Nothing in the bits distinguishes the two — only the declaration does.
Different question, same family: some C library functions read a leading zero as octal, so one string can mean two addresses in one system. The pattern library's IPv4 entry rejects them for that reason.
Because JavaScript's bitwise operators convert to a signed 32-bit integer before acting. `1 << 32` is 1 and `0xFFFFFFFF | 0` is −1. Computing the 64-bit row with them would be silently wrong, and wrong in exactly the way this tool is here to explain.
That the value is beyond the range a JavaScript number represents exactly, so `JSON.parse` would already have rounded it. It is why 64-bit identifiers are sent as strings in JSON — the API returned the right number and the client silently changed it.