Decimal to Hex Converter
A decimal whole number as hex and binary, side by side.
Result
How it is calculated
The tool takes a non-negative whole number and shows it in base 16 and base 2. The hex digits are found by repeated division: n = 16 × q + r, where each remainder r (0 to 15, with 10 to 15 written A to F) is one hex digit, read from the last remainder back to the first. The result is shown with an 0x prefix and upper-case letters; the binary result has no prefix and no leading zeros. Zero returns 0x0 and 0. Negative numbers, numbers with a fractional part (such as 10.5) and numbers containing a comma such as 1,000 give no result, and so does anything larger than 253 (9007199254740992), the largest range the tool can hold exactly. It does not produce two's-complement forms for negatives.
Worked example
Convert 3054. Dividing by 16: 3054 = 16 × 190 + 14, so the last hex digit is E. Then 190 = 16 × 11 + 14, giving another E. Finally 11 is below 16, so it is the leading digit B. Reading the remainders back gives 0xBEE. Replacing each hex digit with 4 bits (B = 1011, E = 1110, E = 1110) gives the binary form 101111101110.
Common mistakes
- Entering a negative number and expecting a two's-complement result such as FFFFFFFB for −5. Negative input is rejected.
- Typing a decimal fraction like 10.5, or a value with a comma like 1,000, which is rejected. A dot is always a decimal point, so 1.000 is read as 1, not one thousand; type 1000.
- Reading the result as a pair of bytes when the digit count is odd. 0xBEE is three digits, so as bytes it is 0x0BEE; pad with a leading zero when a byte-aligned value is needed.
- Mixing up the digits after 9. A is 10, B is 11 and F is 15, so 0x1F is 31, not 1 followed by 15 as separate decimal numbers.
- Entering integers near or above 253 and trusting every digit. At that size ordinary number precision runs out, so keep values below about 15 digits when you need an exact conversion.
About this calculator
Hexadecimal (base 16) uses digits 0-9 and letters A-F, and it's the standard way programmers represent binary data compactly because each hex digit maps to exactly 4 bits — so a byte (8 bits) is always exactly two hex digits (00 to FF), whereas in decimal the same byte takes anywhere from one to three digits (0 to 255) that don't line up with its bits. Converting decimal to hex means repeatedly dividing by 16 and reading the remainders in reverse, while decimal to binary is the same process dividing by 2.
Software developers, systems programmers, and web designers use hex constantly — for memory addresses and pointers, byte values in a debugger, CSS colour codes (#RRGGBB), and error/status codes — because it's dramatically shorter to read and write than the equivalent binary while still mapping cleanly onto binary structure.
Was this helpful?
You can pick up to 3 reactions.
Popular calculators
Loan Calculator
Monthly payment, total interest and full amortization schedule.
Percentage Calculator
Percent change, percent of, and ratio calculations.
Discount Calculator
Calculate final price, savings, and discount amount.
BMI Calculator
Body mass index from height and weight (metric or imperial).
Age Calculator
Compute your exact age in years, months and days from a birth date.
Compound Interest Calculator
Calculate the final amount and interest earned with compounding.
All Calculators
- Loan Calculator
- Profit Calculator
- Discount Calculator
- BMI Calculator
- Percentage Calculator
- Ideal Weight Calculator
- Age Calculator
- Pregnancy Due Date Calculator
- Compound Interest Calculator
- BMR Calculator (Basal Metabolic Rate)
- Tip Calculator
- Fuel Cost Calculator
- Date Difference Calculator
- Sleep Cycle Calculator
- Daily Water Intake Calculator
- Simple Interest Calculator
- Heart Rate Zones Calculator
- Running Pace Calculator
- Pet Age Calculator
- Calories Burned Calculator
- Macro Calculator
- TDEE Calculator (Total Daily Energy Expenditure)
- Waist-to-Hip Ratio Calculator
- Honor Roll Calculator
- One Rep Max (1RM) Calculator
- Ovulation Calculator
- Electricity Cost Calculator
- Unit Price Calculator
- Savings Goal Calculator
- Break-Even Point Calculator
- Paint Calculator
- Course Grade Average Calculator
- Business Days Calculator
- Time Duration Calculator
- Fuel Economy Calculator
- Temperature Converter
- Tile Calculator
- Aspect Ratio Calculator
- Roman Numeral Converter
- Goal Weight Timeline Calculator
- Salary Converter (Hourly to Annual)
- Credit Card Validator (Luhn)
- Body Surface Area (BSA) Calculator
- Feels-Like Temperature Calculator
- Ohm’s Law Calculator
- PPI (Pixel Density) Calculator
- Molar Mass Calculator
- Zodiac Sign Calculator (Western + Chinese)
- IBAN Validator
- Shoe Size Converter
- Country Info & Dialing Code Lookup
- Time Zone Difference (World Clock)
- CAGR (Compound Annual Growth Rate) Calculator
- Rule of 72 Calculator
- Blood Alcohol Content (BAC) Calculator
- Lean Body Mass (LBM) Calculator
- Pythagorean Theorem Calculator
- Speed Converter
- Download Time Calculator
- Date Calculator (Add/Subtract)
No calculators found
Comments (1)
For colour codes, convert each channel from 0 to 255 on its own and pad to two digits yourself, because the tool prints 0xA for 10, not 0A. It handles non-negative whole numbers up to 2 to the power 53, so negatives, which would need two's complement, are not supported. Do you need fixed-width output, such as 8 or 16 bits, or two's complement? Tell us which you would use.