Binary / Hex / Decimal Converter
Type a number in any base and see it in all the others at once. Choose the bit width and whether the value is unsigned or two's complement, and inspect the individual bytes in either endianness.
Bytes (big endian)
Why bit width matters
A number on its own has no fixed size, but in a CPU register, a database column or a network packet it does. The same bit pattern 11111111 is 255 as an unsigned 8-bit value and -1 as a signed one. Setting the width to match the type you are working with, such as an int32 or a uint8, makes the converter show exactly what your program will see, including how out-of-range values wrap.
Two's complement in one paragraph
Two's complement is how almost every computer stores negative integers. The top bit acts as a sign, and to negate a value you invert every bit and add one. That trick means addition and subtraction work with the same circuitry for positive and negative numbers. Switch the sign mode to two's complement and enter a negative decimal to see the resulting bit pattern, or paste a hex value like FFFFFFFE to see that it is -2 as a 32-bit signed integer.
Bytes and endianness
Multi-byte integers can be stored with the most significant byte first, called big endian, or last, called little endian. x86 and ARM processors are little endian, while network protocols and many file formats are big endian. The byte view shows the value split into bytes and flips between the two orders, which is useful when reading a hex dump or debugging a binary protocol.
Frequently asked questions
- How do I convert a negative number to hex?
- Set the sign mode to two's complement and pick the bit width of the type you are targeting, then type the negative decimal. The hex field shows the pattern a 32-bit or 64-bit integer would hold.
- What is the largest number it supports?
- Up to 64 bits, so 18,446,744,073,709,551,615 unsigned or 9,223,372,036,854,775,807 signed. Arithmetic uses BigInt so there is no floating point rounding.
- Why does my value change when I lower the bit width?
- Values are masked to the selected width, exactly as they would be when stored in a smaller integer type. Bits above the width are discarded, which is what an overflow looks like in real code.
- Is anything sent to a server?
- No. All conversion happens in your browser with no network requests after the page loads.