CalcWorldHub
Free online calculator · no signup

Unsigned LEB128 integer encoding calculator

Encode an unsigned integer as base-128 little-endian variable-length bytes.

4,000 tools
Unsigned LEB128 integer encoding calculator — Unsigned integer in decimal and calculation method
Unsigned LEB128 integer encoding calculator: inputs and calculation method.

How to use this calculator

Encode an unsigned integer as base-128 little-endian variable-length bytes.

  1. Enter Unsigned integer in decimal. Match the units shown beside each field and review the result together with the assumptions below.
  2. Read the worked example below to check the expected input format and result.
  3. Compare another scenario by changing one input at a time. Use Reset to return to the starting values.
Calculation guide

Unsigned LEB128 integer encoding explained

Unsigned LEB128 packs a nonnegative integer into seven-bit groups, least-significant group first. Each emitted byte uses its high bit to say whether another group follows. The output is a byte sequence, not an ordinary little-endian integer dump.

Inputs, symbols, and units

n — Unsigned integer in decimal
An exact unsigned decimal integer from 0 through 18446744073709551615 (2⁶⁴−1). Do not enter a rounded floating-point approximation.

Formula and method

Repeatedly take n mod 128 as the next payload, divide n by 128 using integer division, and set the continuation bit when more payload remains.

Supports decimal integers from zero to 2⁶⁴−1; wire tags and other framing are excluded.

A worked scenario

Unsigned integer in decimal = 624485.

  • ULEB128 bytes: e5 8e 26 hex
  • Encoded length: 3 bytes

The seven-bit payloads are 101, 14 and 38. The first two bytes receive continuation bits, giving hexadecimal e5 8e 26. For zero, the encoding is one byte 00.

Assumptions and edge cases

Supports decimal integers from zero to 2⁶⁴−1; wire tags and other framing are excluded.

Frequently asked questions

Why is the high bit set?

It indicates that another byte follows.

Is byte order the same as ordinary integer endianness?

It is an order of seven-bit groups.

Does zero need a byte?

Yes, 00.

How do I use the Unsigned LEB128 integer encoding calculator?

Enter Unsigned integer in decimal. Match the units shown beside each field and review the result together with the assumptions below.

What is a worked example of Unsigned LEB128 integer encoding?

Unsigned integer in decimal = 624485. ULEB128 bytes: e5 8e 26 hex Encoded length: 3 bytes The seven-bit payloads are 101, 14 and 38. The first two bytes receive continuation bits, giving hexadecimal e5 8e 26. For zero, the encoding is one byte 00.