Calculate the last IPv6 /128 with exact integer math

Index the final IPv6 address under ::/0 and check how the planner represents values beyond JavaScript’s safe Number range.

Try these inputs

Worked calculation

  1. A /0 contains 2¹²⁸ possible /128 leaves. The final index is 2¹²⁸ − 1.
  2. A /128 advances one address per index. With parent start 0, the final index directly equals the address integer.
  3. All 128 bits of that address are set. The formatted result is ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128.

Inputs

Prefix lengths
Zero-based. The first child has index 0.

Calculated in your browser

Results

Selected child
ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128
Selected leaf
ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128
Child prefixes
340,282,366,920,938,463,463,374,607,431,768,211,456

IPv6 prefix tree

IPv6 prefix treeThe parent connects to nearby child prefixes. The selected child connects to nearby leaf prefixes. Full CIDRs and indices appear in the table.::/0::/0ffff:ffff:ffff:ffff:ffff:ffff:ffff:fffd/128ffff:ffff:ffff…ffd/128ffff:ffff:ffff:ffff:ffff:ffff:ffff:fffe/128ffff:ffff:ffff…ffe/128ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128ffff:ffff:ffff…fff/128ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128ffff:ffff:ffff…fff/128/0 → /128 → /128
  • Selected prefix
  • Nearby or parent prefix
The parent connects to nearby child prefixes. The selected child connects to nearby leaf prefixes. Full CIDRs and indices appear in the table.
Parent network
::/0
Last address in parent
ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
Full address
0000:0000:0000:0000:0000:0000:0000:0000
Compressed address
::
Addresses in parent
340,282,366,920,938,463,463,374,607,431,768,211,456
Leaves in selected child
1
Address space
IPv6
Prefixes near the selected indices
LevelIndexPrefixSelection
Child340282366920938463463374607431768211453ffff:ffff:ffff:ffff:ffff:ffff:ffff:fffd/128Neighbor
Child340282366920938463463374607431768211454ffff:ffff:ffff:ffff:ffff:ffff:ffff:fffe/128Neighbor
Child340282366920938463463374607431768211455ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128Selected
Leaf0ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128Selected

Questions

Will converting the last IPv6 index to a JavaScript Number preserve it?

No. Keep it as BigInt or a decimal string to retain the exact value.

How long is the decimal string for the last IPv6 address?

The unsigned maximum has 39 decimal digits.

References