timotheecour / Nim

Nim is a compiled, garbage-collected systems programming language with a design that focuses on efficiency, expressiveness, and elegance (in that order of priority).
http://nim-lang.org/
Other
2 stars 0 forks source link

exponentiation #74

Open timotheecour opened 4 years ago

timotheecour commented 4 years ago

D20200325T154113

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

ringabout commented 3 years ago

Integer pow already exists in JS backend:

import jscore

echo Math.pow(2, 4)  
timotheecour commented 3 years ago

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)

ringabout commented 3 years ago

Natural pow exists

import math

echo 2 ^ 2
# 4