Calculation notebook · use case

Read Binary and Hexadecimal as Exact Unsigned Integers

Changing a radix changes how an integer is written, not its value. The converter handles unsigned whole numbers. A bit pattern’s meaning in a file or protocol also depends on signedness, width and byte order, which are separate choices.

Expand the place values

Binary 101101 has place values 32, 16, 8, 4, 2 and 1. Its set positions contribute 32 + 8 + 4 + 1 = 45. Hexadecimal 2D gives 2 × 16 + 13 = 45. Both represent the same positive integer.

Group binary digits into fours

Pad on the left only for presentation, then group 0010 1101. The first group is hexadecimal 2 and the second D. Padding with leading zeroes leaves the unsigned value unchanged; appending zeroes on the right changes the value by powers of two.

Group binary digits into fours
RepresentationValue
101101₂45
0010 1101₂45
2D₁₆45
2D0₁₆720

Validate digits before converting

Binary permits only zero and one; hexadecimal permits zero through nine and A through F. The tool expects digits without 0b or 0x prefixes. A string such as 102 is invalid in binary even though it is a valid decimal string. An empty string should not silently become zero.

Do not infer a signed value from bits

Binary 11111111 represents unsigned 255. In an explicitly chosen eight-bit two’s-complement system it may represent −1, but the unsigned converter does not make that interpretation. Likewise, the hexadecimal byte sequence 01 00 can mean different multi-byte integers depending on endianness. Remove spaces only if you intentionally mean one unsigned digit sequence.

Preserve large integers when copying

Numbers above the safe range of ordinary floating-point integer arithmetic can lose low-order digits. Exact integer conversion avoids this by operating on the digit sequence and large integers. Keep the output as text when transferring it to software that might automatically coerce it to a floating-point number.

Verify digits with a place-value sum

Binary 100000000 is 2⁸ = 256, and hexadecimal 100 is 16² = 256. Their numeral lengths differ because each hexadecimal position stores a power of sixteen while each binary position stores a power of two. A second example, hexadecimal 1234, expands to 1 × 4096 + 2 × 256 + 3 × 16 + 4 = 4660. Its binary numeral is 1001000110100.

Grouping that binary value from the right gives 0001 0010 0011 0100 after presentation padding. Those four groups read as hexadecimal 1, 2, 3 and 4. The extra leading zeroes do not change the unsigned integer. Inserting a zero at the right would multiply the binary integer by two, so padding direction should be stated rather than treated as a cosmetic choice anywhere in the string.

Demonstrate why exact text matters above floating-point limits

The integer 9,007,199,254,740,991 is 2⁵³ − 1 and has hexadecimal form 1FFFFFFFFFFFFF. Two larger is 9,007,199,254,740,993, whose hexadecimal form is 20000000000001. An ordinary JavaScript Number cannot represent every integer in this range and may round the latter to 9,007,199,254,740,992. Preserving the decimal digit string and converting through exact integers retains the final one instead of silently replacing it.

The converter returns exact base numerals as strings. Keep them as text when copying into a spreadsheet, JSON record or application that otherwise coerces digits into an ordinary floating-point number. A notation change does not fix an input that was rounded before arrival. If the original source already supplied a rounded numeric value, recover the original digit string before claiming an exact conversion.

Distinguish an integer numeral from an encoded field

The unsigned hexadecimal numeral FF is 255. In an explicitly chosen eight-bit two’s-complement interpretation, that same bit pattern can mean −1. Adding another leading FF byte can likewise change a wider signed interpretation without changing the relationship between hexadecimal and binary digits. The converter does not guess signedness or width; its output remains the unsigned value of the supplied digit sequence.

A byte pair written 01 00 would represent 256 if the first byte is the most significant, or one if the first byte is the least significant. Removing the separator and entering 0100 deliberately chooses the positional numeral 256. It does not perform an endianness analysis of a byte array. Preserve protocol width and byte order separately when a mathematical conversion is only one stage in reading an encoded field.

Validate and round-trip without changing the source meaning

Select the source base and provide only its permitted digits. The form accepts FF for hexadecimal but not a 0x prefix, and accepts 101 for binary but not 0b101. Decimal input is an unsigned whole-number digit sequence; a minus sign or decimal point requests a different domain. Spaces and underscores are not silently removed, avoiding an accidental merger of separate fields into one integer.

For a round-trip audit, copy the hexadecimal output, choose hexadecimal as the new source and confirm that decimal returns the original exact string value after harmless leading-zero normalization. The input length cap prevents unbounded digit sequences from becoming a resource problem. The tool does not decode floating-point encodings, character codes or packed structures. Exact radix arithmetic verifies the numeral, not every possible interpretation of the bits in a file or device.

Questions and checks

Does FF mean −1?

As an unsigned hexadecimal integer it means 255. A signed interpretation requires an explicit bit width and representation.

Do leading zeroes change the number?

No for unsigned positional notation, though a protocol may require a specific field width.

Does the converter handle byte order?

It converts a digit sequence, not a byte-array encoding. Endianness is a separate interpretation.

Sources and scope

The examples are illustrative calculations, not records of individual users. Check the policy or measurements that apply to your situation.

Try the calculations