nitlanguage
/
nit.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
98b5776
)
lib: add Int::** for power
author
Jean Privat
<jean@pryen.org>
Sat, 8 Nov 2014 01:34:43 +0000
(20:34 -0500)
committer
Jean Privat
<jean@pryen.org>
Sat, 8 Nov 2014 03:58:09 +0000
(22:58 -0500)
Signed-off-by: Jean Privat <jean@pryen.org>
lib/standard/math.nit
patch
|
blob
|
history
diff --git
a/lib/standard/math.nit
b/lib/standard/math.nit
index
a2e0966
..
f6f5397
100644
(file)
--- a/
lib/standard/math.nit
+++ b/
lib/standard/math.nit
@@
-83,6
+83,14
@@
redef class Int
#
# assert not 13.is_even
fun is_odd: Bool do return not is_even
+
+ # Returns the `self` raised to the power of `e`.
+ #
+ # assert 2 ** 3 == 8
+ fun **(e: Int): Int
+ do
+ return self.to_f.pow(e.to_f).to_i
+ end
end
redef class Float