IntegerSquareRoot
function · spline · primitive
- Address
0x454a10· 117 bytes, up to0x454a84- Signature
uint32_t __fastcall (uint32_t n)- Meaning
- Returns the floor of the square root of n
- Confidence
- verified, proof one
- Finding
- spline#integer-square-root
- Test
spline::isqrt_diff
Finding: Integer square root in spline
0x454a10(n), with n in ecx, returns ⌊√n⌋ in eax for every unsigned 32-bit n. The first
estimate is ⌊n·0xaaaaaaab/2³⁵⌋ + 1 for n ≤ 0xff, ⌊n·0x51eb851f/2³⁸⌋ + 21 for n ≤ 0xffff, and
otherwise ⌊(⌊(n − t)/2⌋ + t)/2¹⁴⌋ + 0x1bc with t = ⌊n·0x39acc69d/2³²⌋. Each step is q = n / e,
d = e − q, e = (q + e)/2, both halves truncating toward zero, and the loop ends when d/2 is 0.
The derivation is in the doc.
Callers 1
Callees 0
None by a direct call or jump.
Calls and jumps by a bare address, from tables/calls.tsv.