Open timotheecour opened 4 years ago
Integer pow
already exists in JS backend:
import jscore
echo Math.pow(2, 4)
Integer pow
already exists in JS backend:
note that output is a float, not the original type (yes, they map to js Number, but the nim type matters)
Natural pow
exists
import math
echo 2 ^ 2
# 4
D20200325T154113
[x] we need integer exponentiation in stdlib EDIT: this is:
math.^
[ ] best? https://gist.github.com/orlp/3551590 more optimized than the squaring version
http://www.cplusplus.com/reference/cmath/pow/
https://stackoverflow.com/questions/20872689/how-to-raise-to-the-power-of/20872712
https://stackoverflow.com/questions/41403730/c-exponentiation-with-non-integer-exponent
https://stackoverflow.com/questions/101439/the-most-efficient-way-to-implement-an-integer-based-power-function-powint-int
https://en.wikipedia.org/wiki/Exponentiation_by_squaring
js
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Browser_compatibility https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Browser_compatibility
revisit this:
https://github.com/nim-lang/Nim/pull/12455