Convert binary, decimal, and hexadecimal in the browser
Specify the input radix, Bit Width, and Signed / Unsigned, then check the integer and two's complement results without sending data externally.
Open the decimal conversion toolConclusion: FF is 255 as unsigned 8-bit and -1 as signed 8-bit
FF=15×16+15=255. Reading the same 8-bit pattern as signed gives 255-256=-1.
If 00FF is 16-bit, it is 255 even when signed. Do not conclude it is -1 from the characters FF alone.
Do not judge based only on displayed values; check the original radix, Bit Width, and Signed / Unsigned.
Calculate FF as both a number and an 8-bit pattern
One hexadecimal digit is 4 bits, so FF is 8 bits. Even if the most significant bit is 1, it is not negative when unsigned.
In the current tool, entering 255 as 8-bit unsigned lets you view the signed result, -1, alongside it.
| Account to check | What to check | judgment |
|---|---|---|
| Hex | FF | Unsigned 255 |
| Binary | 11111111 | 8bit |
| Unsigned | 0~255 | 255 |
| Signed | -128~127 | -1 |
Procedure for checking with the radix conversion tool
- Enter FF as hexadecimal.
- Verify the normal result, 255.
- Set the two's-complement field to 8-bit and unsigned.
- Check the Signed result -1.
Directly entering -1 as Signed also produces the same FF Pattern.
Conditions under which FF does not become -1
- Read as a normal hexadecimal value
- Read as 16-bit 00FF
- Read as an Unsigned Byte
Signedness is determined by the data type or protocol specification, not by the string FF.
Read numeric values and bit patterns separately
Binary, decimal, and hexadecimal can represent the same numeric value in different bases. In contrast, the value of a fixed-width bit pattern changes depending on whether it is read as signed or unsigned. The 8-bit value 11111111 is 255 when unsigned and -1 as signed two's complement. Do not determine a value from FF or 11111111 alone; record the original base, bit width, and signed/unsigned interpretation together.
| Bit Pattern | Bit Width | Interpretation | decimal number |
|---|---|---|---|
| 11111111 / FF | 8bit | Unsigned | 255 |
| 11111111 / FF | 8bit | Signed Two’s Complement | -1 |
| 00000001 / 01 | 8bit | Unsigned / Signed | 1 |
| 10000000 / 80 | 8bit | Signed Two’s Complement | -128 |
When sharing conversion results, do not provide only “FF”; include type information such as “read 0xFF as uint8” or “read 0xFF as two's-complement int8.” This lets recipients reproduce either 255 or -1.
Choose the bit width first for two's complement.
Fixed-width two's complement is a bit pattern modulo 2^BitWidth. Even for the same -1, 8-bit is 11111111, 16-bit is 1111111111111111, and 32-bit has 32 ones. Simply asking to "convert -1 to binary" cannot uniquely determine a fixed-width answer.
A typical procedure for obtaining a pattern from a negative number is to write the positive absolute value at the specified width, invert every bit, and add 1. For reverse conversion, if the most significant bit is 1, subtract 2^BitWidth from the unsigned value. In either direction, changing the bit width changes the pattern and representable range.
Sign extension that widens a negative number fills upper bits with 1. Zero extension for positive or unsigned values fills upper bits with 0. It is important not to confuse numeric notation that can omit leading zeros with fixed-width patterns where digit count has meaning.
| Bit Width | Signed range | Unsigned range | Hex pattern for -1 |
|---|---|---|---|
| 8bit | -128 ~ 127 | 0 ~ 255 | FF |
| 16bit | -32768 ~ 32767 | 0 ~ 65535 | FFFF |
| 32bit | -2147483648 ~ 2147483647 | 0 ~ 4294967295 | FFFFFFFF |
| 64bit | -9223372036854775808 ~ 9223372036854775807 | 0 ~ 18446744073709551615 | FFFFFFFFFFFFFFFF |
How to isolate issues when conversion results are wrong
When 255 and -1 conflict, check the signedness of the data type before the conversion formula.
By fixing the input radix and prefix, allowed digits, bit width, and signed/unsigned status in order, you can isolate where the meaning changed: the calculation, display format, or type. After converting the original value to another radix, also perform a round trip back to the original radix.
- Check the radix and bit width specified in the input source documentation.
- Check whether the specified input base matches 0b, 0o, or 0x.
- Preserve leading zeros and the most significant bit in fixed-width patterns
- Do not implicitly truncate values outside Signed or Unsigned ranges.
- Convert the result back to the original radix and confirm it matches.
Supported scope of the current radix conversion tool
DevelopTools' base converter reads integers and negative numbers in bases 2 through 36 with BigInt, then converts them to binary, octal, decimal, hexadecimal, and one arbitrary base. Input values and conversion results are processed only in the browser and are not sent to or saved on a server.
| Item | Current tool operation |
|---|---|
| Input | Sign, 0b/0o/0x, commas, spaces, underscores, and integers in bases 2–36 |
| Standard conversion | Display binary, octal, decimal, hexadecimal, and one arbitrary base together. Choose uppercase or lowercase hexadecimal letters. |
| Display | Support 0b, 0o, and 0x prefixes and separators every 4 or 8 digits. |
| Two's complement | Display binary and hexadecimal bit patterns as signed or unsigned 8-, 16-, 32-, or 64-bit values. |
| verification | Display invalid digits, prefix/radix mismatches, and values outside signed/unsigned ranges in Japanese. |
| Unsupported | Decimals, arbitrary bit widths, arbitrary-digit zero padding for standard conversion, and sign/zero extension for calculations only |
In standard conversion, -101 is a signed numeric notation, not a fixed-width two's-complement bit pattern. To check a fixed-width negative number, select "two's complement/signed integer" and specify the bit width and input interpretation.
Check language specifications and official documentation
Use each language's official documentation for language-specific negative-number displays, integer widths, and overflow. In JavaScript, distinguish Number's safe integer range from 32-bit conversion by bitwise operators, and use BigInt for large integers such as 64-bit values.
Example: Verify the same FF as 255 and -1
Convert FF normally, then read it as an 8-bit pattern.
Standard conversion produces 255, while the 8-bit signed result is -1, making the difference in interpretation clear.
- FF input
- Check 255
- Specify 8-bit unsigned.
- Check -1
When sharing, include the type, such as 0xFF (uint8) or 0xFF (int8).
Frequently asked questions
- Is hexadecimal FF 255 or -1?
- It can be either. It is 255 for 8-bit Unsigned and -1 for 8-bit Signed Two's Complement. Check Bit Width and Signed / Unsigned.
- Is bit width required when calculating two's complement?
- It is required for fixed-width two's complement representation. Even for the same -1, the Bit Pattern digit count differs between 8bit and 16bit.
- Why do leading zeros disappear after converting to binary?
- This is because the value is unchanged by the presence or absence of a leading Zero. If you need a fixed-width Bit Pattern, use Zero Padding to the required Bit Width.