toolfree

Hex to decimal

Convert hexadecimal to decimal in your browser with arbitrary precision, so 64-bit hex values convert exactly.

Runs in your browser

Enter a number.

Where the usual converters break

Hex is how large numbers are usually written down, which means hex-to-decimal is exactly where precision loss shows up.

A 16-digit hex value — that is, 64 bits — exceeds what a JavaScript number can hold exactly. 0xFFFFFFFFFFFFFFFF is 18446744073709551615, and a converter built on parseInt gives you 18446744073709552000. The last four digits are invented.

This uses arbitrary-precision integers, so the answer is exact however long the input is.

What you can paste

The 0x prefix is optional, case does not matter, and underscores or spaces between digits are ignored — so 0xDEAD_BEEF, DEADBEEF and de ad be ef are all the same value.

A character that is not a hex digit is reported by name rather than skipped.

Reading a hex value as a signed number

Hex usually appears where the width matters, so the conversion also shows the two’s-complement reading at 8, 16, 32 and 64 bits where the value fits.

0xFF is 255 as an unsigned byte and −1 as a signed one. 0x80000000 is 2147483648 unsigned and −2147483648 as a signed 32-bit integer — the value that famously has no positive counterpart.

Colours are a different thing

A hex colour like #1a2b3c is three separate byte values — red, green and blue — not one number. Converting it as a single value gives 1715004, which is arithmetically correct and useless. Use the colour tools for that.

Nothing is uploaded

Converted in this page.