Decimal 42 is binary 101010, octal 52 and hexadecimal 2A. If you are checking classwork or reading a log, determine the input radix first. For a bit pattern check its width and signedness. For text, confirm the encoding.
Binary, octal, decimal and hexadecimal at a glance
| Radix | Digits | 42 written in that base | Example use |
|---|---|---|---|
| 2 | 0 and 1 | 101010 |
Bit patterns |
| 8 | 0–7 | 52 |
Permission notation |
| 10 | 0–9 | 42 |
Counts and displays |
| 16 | 0–9 and A–F | 2A |
Bytes and logs |
The rightmost digit has weight 1 in every base. Decimal 123 means 1×100 + 2×10 + 3. In binary 101010, the set digits contribute 32 + 8 + 2 = 42.
Convert decimal to binary by reading remainders backwards
Dividing 42 by 2 gives remainder 0 and quotient 21. Keep dividing each quotient by 2 until it reaches zero. The remainders in the order produced are 0, 1, 0, 1, 0, 1. Read the last remainder first to get 101010.
Convert binary to hex by grouping four bits from the right
| Binary | Hex | Binary | Hex |
|---|---|---|---|
| 0000 | 0 | 1000 | 8 |
| 0001 | 1 | 1001 | 9 |
| 0010 | 2 | 1010 | A |
| 0011 | 3 | 1011 | B |
| 0100 | 4 | 1100 | C |
| 0101 | 5 | 1101 | D |
| 0110 | 6 | 1110 | E |
| 0111 | 7 | 1111 | F |
In reverse, write each hex digit as four bits. 3F becomes 0011 1111. Leading zeroes can be dropped for an integer value. Keep them when a byte or file field specifies an eight-bit width. For octal, group three bits from the right. 101 010 becomes 52.
Try the worked example
Convert 101010 from binary
Select base 2 and enter 101010. Compare octal 52, decimal 42 and hex 2A.
When is FF 255, and when is it −1?
| Task | Interpret the input as | Result |
|---|---|---|
| Convert an integer | Hexadecimal FF |
Decimal 255 |
| Read signed 8-bit data | Two’s complement 11111111 |
−1 |
| Read signed 16-bit data | Two’s complement 00FF |
255 |
| Decode text | One UTF-8 byte 41 |
A |
In a w-bit two’s-complement representation with its top bit set, subtract 2 to the power of w from the unsigned value. FF is 255 as an unsigned number and 255 − 256 = −1 as an eight-bit signed pattern. The 16-bit 00FF has its top bit clear and remains 255. In JavaScript, BigInt.asIntN(8, 255n) checks the eight-bit interpretation.
This converter changes integer notation. Entering decimal -1 therefore returns -1 in hex. Specify a width such as eight or 16 bits before encoding a fixed-width bit pattern.
Check invalid digits, prefixes and large integers
- Select the source radix. For
0xFF, select hexadecimal and enter onlyFF. - Check for decimal points, separators, prefixes and out-of-range digits. Binary
102and octal8are invalid. - Record the radix when reusing a copied result. The clipboard contains the digits without display grouping or a radix prefix.
- Start with the original digits when an integer exceeds the JavaScript safe range. Decimal
9007199254740993is hex20000000000001. Converting a JavaScript Number that has already rounded the value cannot recover the original digits.
Try the worked example
Check an integer above the safe range
Enter decimal 9007199254740993, copy the hex result and compare it with 20000000000001.
If a log stores Unix milliseconds in hexadecimal, convert 18BCFE5687B to decimal 1700000000123 before using the Unix timestamp guide. If the value is a UUID, see its hex groups and version field. To read encoded text, use the hex and UTF-8 guide. Find the related tools in the developer tools category.
Editorial verification
Tools Hub editors checked the specifications, worked arithmetic and integer conversion on November 9, 2026. The examples are calculated values. Confirm the source format when working with fixed-width integers or text.
FAQ
What is binary 101010 in hexadecimal?
Group four bits from the right and pad the left group to obtain 0010 1010. These map to 2 and A, so the hexadecimal result is 2A and the decimal value is 42.
Does FF mean 255 or −1?
As an ordinary hexadecimal integer it is 255. As an eight-bit two’s-complement pattern it means 255 − 256 = −1. In 16 bits, −1 is FFFF.
Can I paste 0xFF or 0b1010 into this tool?
Select the radix separately and enter FF for base 16 or 1010 for base 2. Remove the prefixes and any spaces inside the number.
Can I convert fractions or decode text here?
The base converter takes integers. For UTF-8 text, use Hex to Text. Hex 41 is the integer 65, and the byte 41 encodes the character A in UTF-8.