๐Ÿ”ข Base Converter

Bit width

Convert between binary, octal, decimal, and hexadecimal in real time. Set a bit width (8/16/32/64-bit) to check the two's-complement bit representation and catch out-of-range values โ€” handy for programming and embedded development. Type a value into any field and the others update instantly, so there's no need to reach for a separate calculator or work it out by hand.

How to use

  1. Type a value into any one field โ€” binary, octal, decimal, or hexadecimal.
  2. The other fields update automatically in real time.
  3. Optionally choose a bit width (8/16/32/64-bit) to see the two's-complement bit representation.
  4. Press Clear to reset the inputs and convert a new value.

How the calculation works

A number base is the rule for how many values a single digit can hold. Decimal uses ten symbols (0โ€“9), binary two (0 and 1), octal eight (0โ€“7), and hexadecimal sixteen (0โ€“9 then Aโ€“F for 10โ€“15). Each digit is weighted by a power of the base, so hexadecimal "2F" is 2ร—16 + 15ร—1 = 47. Computers work in binary internally, but long binary strings are hard to read. Hexadecimal is popular because one hex digit maps exactly onto four bits, so a byte (eight bits) is always exactly two hex digits, 00 to FF. Negative numbers are stored in two's complement. For a bit width n, a negative value is represented by the bit pattern of that value plus 2^n. In 8 bits, โˆ’5 becomes โˆ’5 + 256 = 251, or 11111011 in binary. This tool computes with BigInt internally, so even 64-bit values convert without losing digits.

Worked example

Converting decimal 200 Binary: 200 = 128 + 64 + 8 โ†’ 11001000 Octal: 200 = 3ร—64 + 1ร—8 + 0 โ†’ 310 Hexadecimal: 200 = 12ร—16 + 8 โ†’ C8 In 8 bits, โˆ’56 is โˆ’56 + 256 = 200, so its bit pattern is the same 11001000. The same bits read as 200 when treated as unsigned and โˆ’56 when treated as signed โ€” the defining property of two's complement.

Things to be aware of

  • Integers only; values with a fractional part cannot be converted.
  • Negative values depend on bit width. Choose the width that matches the type your code uses (int8, int32 and so on).
  • Hexadecimal input accepts Aโ€“F in either upper or lower case.
  • Values that do not fit the chosen width are flagged as out of range. A signed 8-bit value, for instance, spans โˆ’128 to 127.

FAQ

Can it handle negative numbers?

Values within the selected bit width are treated as two's complement; anything outside that range is flagged as out-of-range.

When would I use this?

Checking bitwise operations while programming, converting hex color codes or IP address octets, or inspecting register values in embedded development.

Can I convert an IP address to hex?

Yes โ€” enter the decimal value and the hex field updates instantly, which works well for converting IP octets or color codes.

Can it convert decimal numbers?

This tool is built for integer base conversion; values with a fractional part may not convert correctly.

Which bit widths are supported?

8-bit, 16-bit, 32-bit, and 64-bit. Values exceeding the selected width are flagged as out-of-range.