Convert little-endian hexadecimal to decimal

Learn how to convert little-endian hex bytes to decimal, handle signed values, and preserve the byte order and context needed to interpret the result.

When this conversion is suitable

Converting little-endian hexadecimal bytes to decimal is useful when you need a familiar numeric value from a byte dump or binary field. It preserves the integer’s value when the byte order, field boundaries and signedness are interpreted correctly. The tradeoff is that decimal notation alone does not retain the original byte layout or field width. Keep the original hex alongside the decimal result when those details matter.

What little-endian conversion actually changes

Hexadecimal and decimal are different ways to write a number. Little-endian describes the order of bytes in a multibyte value: the least significant byte comes first. Converting those bytes to decimal means interpreting their numeric significance and then expressing the resulting value in base 10. It is not character reversal, mirrored lettering, Unicode substitution or a visual formatting effect.

For an unsigned integer whose bytes are listed in storage order, give the first byte a weight of 1, the second a weight of 256, the third a weight of 65,536, and continue with successive powers of 256. Each byte consists of two hexadecimal digits.

Little-endian bytes: 01 02
Byte values:         1, 2
Decimal calculation: 1 + (2 × 256) = 513
Conventional hex:    0x0201

You can also reverse the order of the byte pairs and read the result as a conventional hexadecimal integer. For 01 02, that gives 0201. Do not reverse the individual characters: reversing the text into 20 10 would change the byte values and produce the wrong result.

Resolve the input’s meaning before converting

First establish whether the input is a sequence of stored bytes or an already written hexadecimal number. The conventional numeric notation 0x0102 represents decimal 258; the little-endian byte sequence 01 02 represents decimal 513 as an unsigned integer. An unlabelled string such as 0102 does not establish which interpretation is intended.

Identify the complete field before applying the conversion. Do not reverse an entire dump containing multiple fields as though it were one number. For a byte sequence, check that each byte has two valid hexadecimal digits, using 0–9 and A–F or a–f. An odd number of digits leaves byte grouping unresolved unless the input format defines how to handle it.

Signedness is a separate decision from byte order. The two-byte sequence FF FF represents 65,535 as an unsigned integer or −1 as a signed 16-bit two’s-complement integer. For a signed two’s-complement field, first calculate the unsigned value. If the highest bit of the most significant byte is set, subtract 2 raised to the field’s bit width.

This integer method is appropriate only when the bytes encode an integer. Floating-point values, encoded text and other structured data require their own interpretation. No input sample or format specification was supplied, so the intended field width, signedness and data type remain unresolved.

Keep the result usable when copying or sharing

Plain decimal digits provide a straightforward text result without special glyphs or display styling. Copying the digits alone, however, leaves their interpretation behind. For human readers, include a label stating the original bytes, byte order, field width and signedness.

Input bytes: 01 02
Byte order: little-endian
Interpretation: unsigned 16-bit integer
Decimal value: 513

Preserve the hex when editing, searching or reconstructing the original data matters. For example, 01 and 01 00 both represent unsigned decimal 1 when interpreted as complete little-endian fields, but their widths differ. A decimal-only record cannot distinguish them, and searching for the original hex text will not match its decimal replacement.

For a destination that requires a bare number, supply only the decimal digits and any required minus sign, keeping the interpretation in a separate record. No destination or assistive-technology documentation or scoped test was supplied, so compatibility, numeric precision and spoken presentation in a particular application are unverified.