Why it matters
Developers meet number bases constantly: hex colours and memory addresses, binary flags, octal file modes, and protocols that pack values into bytes in one order or the other. Most converters stop at 53 bits, where JavaScript numbers lose precision.
This converter uses BigInt, so any size is exact, and shows the same value as signed and unsigned at fixed widths with its bytes in both orders. The float section shows why 0.1 + 0.2 isn't 0.3: it gives the exact value a float really stores.
How it works
- InputA number in any base
- In your browserExact big-integer maths
- OutputBases, two's complement, bytes and floats
Where it fits in a designer's workflow
- Plan
- Design
- Build
- Test
- Launch
By the numbers
0.1 → 0.1000000014901161232-bit, 0x3DCCCCCD0.1 → 0.164-bit, 0x3FB999999999999A0.5 → 0.564-bit, 0x3FE000000000000016777217 → 1677721632-bit, 0x4B800000
Show the numbers as a table
| Value | Bits | Hex | Stored as |
|---|---|---|---|
| 0.1 | 32 | 3DCCCCCD | 0.10000000149011612 |
| 0.1 | 64 | 3FB999999999999A | 0.1 |
| 0.5 | 64 | 3FE0000000000000 | 0.5 |
| 16777217 | 32 | 4B800000 | 16777216 |
How to use it
- Type a number; 0x, 0b and 0o prefixes are detected.
- Pick the width and whether it's signed.
- Click bits to flip them, or try a bitwise operation.
- Type a decimal or raw bits in the float section.
FAQ
Why does -1 show as 255?
In 8 bits, two's complement stores -1 as 11111111, which read as unsigned is 255.
What's the difference between >> and >>>?
>> (arithmetic) copies the sign bit as it shifts, so negative numbers stay negative. >>> (logical) fills with zeros.
Why can't 0.1 be stored exactly?
Floats are binary fractions, and 0.1 has no finite binary form. The nearest float64 is 0.1000000000000000055511151231257827…
Is there a size limit?
Not for integers: they use BigInt. Very large numbers just take longer to display.