BedrockCalculator
Figures cited to primary sourcesWritten by Aapt Dubey, MBA (Marketing & Banking), ISB 2 primary sourcesLast updated

Hex Converter: Hex to Decimal, Binary and Octal

The Hex Converter: Hex to Decimal, Binary and Octal converts hex to decimal, binary and octal, or back again, exactly at any length, with the bits and bytes needed. Accepts 0x and # prefixes and colour codes.

Quick Answer: Hex FF is 255 in decimal, 1111 1111 in binary and 377 in octal. It needs 8 bits, which is 1 byte.

Assumptions

Computed

Preset scenarios

Converted (decimal, or hex if you entered decimal)
255
Decimal
255
Hexadecimal
FF
Binary
1111 1111
Octal
377
Bits needed
8
Bytes needed
1

Hex digits in decimal and binary

Download CSV
Each row is this converter run on a single hex digit. Every value is exact.
HexDecimalBinary
000
111
2210
3311
44100
55101
66110
77111
881000
991001
A101010
B111011
C121100
D131101
E141110
F151111

This table and its CSV are free to reuse with a link to this page, CC BY 4.0.

Common hex values

Download CSV
Each row is this converter run on the hex value in the first column: byte, word and integer limits, and powers of 16.
HexDecimalBits
10165
1A265
1E305
1F315
20326
7F1277
801288
901448
FF2558
1002569
3E81,00010
FFFF65,53516
1000065,53617
7FFFFFFF2,147,483,64731
FFFFFFFF4,294,967,29532
FFFFFFFFFFFFFFFF18,446,744,073,709,551,61564

This table and its CSV are free to reuse with a link to this page, CC BY 4.0.

Hex Converter: Hex to Decimal, Binary and Octal: Converted (decimal, or hex if you entered decimal) 255 (Number to convert: FF; The number is in: Hexadecimal (base 16)).

Save or share this result

A one-page summary of this calculator's default example, drawn from the same calculation as the result above.

The infographic is free to reuse with a link to this page, CC BY 4.0.

Illustration of eighteen glowing square tiles on a dark panel, in rainbow colors from red and yellow to blue
Quick Answer: Hex FF is 255 in decimal, 1111 1111 in binary and 377 in octal. It needs 8 bits, which is 1 byte.

What does this calculator do?

This hex converter turns a hexadecimal number into decimal, binary and octal, and it works in every direction: enter a decimal, binary or octal number and it gives the hex as well. It also says how many bits and bytes the number needs.

Hexadecimal is base 16. It uses the ten digits 0 to 9 and then the letters A to F for the values ten to fifteen. Programmers use it because one hex digit is exactly four binary digits, so a byte (eight bits) is always exactly two hex digits. That makes hex a compact, readable way to write memory addresses, colour codes, file signatures, network addresses and hashes. RFC 4648 calls this the standard hex encoding and notes that it is case-insensitive: ff and FF are the same number.

The converter uses whole-number arithmetic of unlimited length. A pocket calculator or a spreadsheet stops being exact at around 15 decimal digits, which is only about 12 hex digits. Here a 32-digit hex value, or a 64-digit hash, converts exactly.

Using the Hex Converter

  1. Type or paste the number. For hex, upper or lower case both work, and the prefixes 0x and # are accepted. Spaces and underscores between digits are ignored, so FF FF and FF_FF both read as FFFF.
  2. Choose the base the number is written in: hexadecimal, decimal, binary or octal.
  3. Read the decimal value at the top (or the hex value, if you entered decimal). The cards give every form: decimal with thousands separators, hex in byte pairs, binary in groups of four, octal, and the bits and bytes needed.

The presets load a web colour, a decimal number, a byte in binary, and the largest 128-bit number.

How is this calculated?

  1. Clean the input. Spaces and underscores are removed, a leading minus sign is kept, and a prefix matching the chosen base (0x or # for hex, 0b for binary, 0o for octal) is dropped. Any character that is not a digit of that base is rejected with a message naming the allowed digits.
  1. Read the digits as a whole number. Each digit is multiplied by its place value, a power of the base, and the results are added. For hex, the rightmost digit counts ones, the next sixteens, the next 256s, and so on.

value = ∑(k = 0 to n − 1) dₖ × 16ᵏ

  1. Write it in the other bases. The whole number is divided repeatedly by the target base, and the remainders, read from last to first, are its digits. Hex letters are written in upper case.
  1. Group for reading. Hex is grouped in pairs from the right, so each group is one byte. Binary is grouped in fours from the right, so each group lines up with one hex digit. Decimal gets thousands separators.
  1. Count bits and bytes. The bit count is the length of the binary form (ignoring any minus sign); the byte count is that divided by eight and rounded up.

Worked Example

The default is hex FF.

  1. F is fifteen. The right-hand F counts 15 ones and the left-hand F counts 15 sixteens.
  2. 15 × 16 + 15 = 240 + 15 = 255.
  3. In binary, each F is 1111, so FF is 1111 1111.
  4. In octal: 377.
  5. Eight binary digits: 8 bits, or 1 byte.

A web colour, from the Colour #1E90FF preset: the six digits are three bytes, 1E for red, 90 for green and FF for blue, as the CSS Color specification defines hex colours. Read as one number, it is 2,003,199, and it needs 21 bits, or 3 bytes.

How Do You Convert Hex to Decimal?

Multiply each digit by 16 raised to its position, counting from zero on the right, and add. For 7EA: 7 × 256 + 14 × 16 + 10 = 1,792 + 224 + 10 = 2,026. The 2026 in decimal preset runs the same conversion backwards, from decimal 2026 to hex 7EA and binary 111 1110 1010.

How Do You Convert Hex to Binary?

Replace each hex digit with its four-bit pattern from the first reference table. D is 1101 and 6 is 0110, so D6 is 1101 0110; the Binary 1101 0110 preset shows that this byte is 214 in decimal. Going the other way, split binary into groups of four from the right and replace each group with its hex digit.

Common Hex Values

The second reference table lists values that come up again and again: 7F and FF (the largest signed and unsigned byte, 127 and 255), FFFF (65,535, the largest 16-bit value), 7FFFFFFF (2,147,483,647, the largest signed 32-bit integer) and FFFFFFFF (4,294,967,295).

What does this calculator not account for?

  • Two's complement. Negative numbers are written with a minus sign. A computer usually stores them in two's complement, where the same bits read as unsigned would give a large positive number; for example, the byte FF is -1 as a signed 8-bit value. The converter does not reinterpret bits that way.
  • Fractions. Only whole numbers are converted. Hex fractions (such as 0.8 for one half) and floating-point bit patterns are not handled.
  • Text. Hex that encodes characters (such as 48 65 6C 6C 6F) is converted here as one large number, not decoded to letters.
  • Length. Up to 4,096 digits are accepted.

What mistakes do people make with this?

  • Mixing up O and 0, or I and 1. Hex uses only the digits 0 to 9 and the letters A to F. The letter O is not a hex digit.
  • Choosing the wrong input base. "10" is ten in decimal, sixteen in hex, eight in octal and two in binary. Check the base select before reading the answer.
  • Dropping leading zeros you need. 0x0F and 0xF are the same number, but if a format expects two digits per byte, keep the zero.
  • Losing digits in a spreadsheet. Spreadsheets convert large hex values through floating point and silently round them. Use an exact tool for anything over about 12 hex digits.
  • Reading a colour as RGB numbers. #1E90FF is three separate bytes, 30, 144 and 255, not the single number 2,003,199, when you need RGB values.

Frequently Asked Questions

What is FF in decimal?

255. It is the largest value one byte can hold.

How many bits is one hex digit?

Four. That is why two hex digits make one byte and why hex and binary convert digit by digit.

What does 0x mean in front of a number?

It marks the number as hexadecimal in most programming languages. 0x1A is twenty-six. The converter accepts it.

How do I convert a hex colour to RGB?

Split the six digits into three pairs and convert each pair: #1E90FF is 1E, 90 and FF, which the common values table lists as 30, 144 and 255.

Is hex case-sensitive?

No. ff, FF and Ff are all 255. The converter writes hex in upper case.

What is the largest number the converter can handle?

Any whole number up to 4,096 digits long. The 128-bit maximum, 32 F digits, is 340,282,366,920,938,463,463,374,607,431,768,211,455 in decimal.

Sources

  • IETF RFC 4648, The Base16, Base32, and Base64 Data Encodings, section 8: base 16 is the standard case-insensitive hex encoding, four bits per character. doi.org/10.17487/RFC4648
  • W3C, CSS Color Module Level 4: hex colour notation, three pairs of hex digits for red, green and blue. w3.org/TR/css-color-4

Did this calculator answer your question?

How this calculator is tested

This calculator is checked by 7 automated test cases: specific inputs whose correct result is known in advance, and rules the output must always obey. They run on every change to the site. See the testing and corrections policy.

Show the test cases
  • Default: FF is 255, 1111 1111, 377, one byte
  • decimal 2026 is 7EA
  • binary 11010110 is D6, 214
  • a web colour with a # prefix
  • is exact far beyond floating point: 2^128 - 1
  • handles zero, negatives and bad digits
  • builds both reference tables from compute()

Add This Website as Preferred Source on Google

See Bedrock Calculator first in your Search results & AI Overviews