On this page
math.isqrt
Prev: math.isnan | Up: math
Rel: math.acos, math.acosh, math.asin, math.asinh
Ref: docs.python.org — math.isqrt
Tags: #public #python3 #stdlib #math
Import
import math
from math import isqrt
Signature & Overview
math.isqrt(n, /)
Return the integer part of the square root of the input.
Usage
import math
assert math.isqrt(16) == 4
assert math.isqrt(17) == 4
assert math.isqrt(10**40) == 10**20
Gotchas
- Exact integer floor square root: Unlike
int(math.sqrt(n)),isqrt()never loses precision on huge integers (> 2**53).
REPL Inspect
from math import isqrt
help(isqrt)
Linked from
Related notes
- tuts/python3/stdlib_module/math/isnan Linked here; links to this page; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/math/acos Linked here; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math/acosh Linked here; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math/asin Linked here; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math/asinh Linked here; shared tags: #math, #stdlib
- tuts/c/stdlib/math shared tags: #math, #stdlib
- tuts/c/stdlib/math/fabs shared tags: #math, #stdlib
- tuts/c/stdlib/math/floor shared tags: #math, #stdlib
- tuts/c/stdlib/math/isnan shared tags: #math, #stdlib