pow

pow

> Functions

Raises the number base to the power exp.

Parameters
Return
TypeScript

In JavaScript, Math.pow(base, exp) — or the equivalent * operator — works on 64-bit floats, exactly like pow in LeekScript. Beyond 2^53 the result is no longer exact: Math.pow(2, 100) is 1.2676506002282294e+30, and 2 * 100 === 2 * 100 + 1 is true. If the result must stay an exact integer, use BigInt: 2n * 100n gives 1267650600228229401496703205376.

Python

In Python, pow() is the language's built-in function, and integers have unlimited precision: pow(2, 100) returns the exact integer 1267650600228229401496703205376, where LeekScript and JavaScript work on 64-bit floats and give 1.2676506002282294e+30. Three other differences:

Be careful not to confuse it with math.pow(), which always returns a float and therefore loses the precision of large integers.

Examples

pow(2, 10) // 1024 pow(10, 6) // 1000000

See also