Introduce UINT64_MAX_SQRT

This commit is contained in:
Mikhail Kalinin 2024-02-16 13:39:46 +06:00 committed by GitHub
parent cdb6725275
commit 3e2650811e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 1 deletions

View File

@ -179,6 +179,7 @@ The following values are (non-configurable) constants used throughout the specif
| Name | Value |
| - | - |
| `UINT64_MAX` | `uint64(2**64 - 1)` |
| `UINT64_MAX_SQRT` | `uint64(4294967295)` |
| `GENESIS_SLOT` | `Slot(0)` |
| `GENESIS_EPOCH` | `Epoch(0)` |
| `FAR_FUTURE_EPOCH` | `Epoch(2**64 - 1)` |
@ -601,7 +602,7 @@ def integer_squareroot(n: uint64) -> uint64:
Return the largest integer ``x`` such that ``x**2 <= n``.
"""
if n == UINT64_MAX:
return uint64(4294967295)
return UINT64_MAX_SQRT
x = n
y = (x + 1) // 2
while y < x: