It does actually:
(Math/pow 2 3)
;;=> 8It does actually:
(Math/pow 2 3)
;;=> 8If you instead used the library org.clojure/math.numeric-tower [1] you can get much more precise answers, for example
# start a repl with an extra dep
$ clj -Sdeps '{:deps {org.clojure/math.numeric-tower {:mvn/version "0.0.4"}}}'
user=> (require 'clojure.math.numeric-tower)
nil
user=> (Math/pow 33 33)
1.2911004008776103E50
user=> (type *1)
java.lang.Double
user=> (clojure.math.numeric-tower/expt 33 33)
129110040087761027839616029934664535539337183380513N
user=> (type *1)
clojure.lang.BigInt
[1] https://github.com/clojure/math.numeric-towerHum, ok, to my defense it's not the very next sentence, it's much later at the very end when talking about Method invocation, so I hadn't read that far.
+1 for linking to the numeric tower though
No need to pull the library for this, Clojure already has (biginteger) for that:
user=> (.pow (biginteger 33) 33)
129110040087761027839616029934664535539337183380513 user=> (bigint "129110040087761027839616029934664535539337183380513")
129110040087761027839616029934664535539337183380513N
user=> (type *1)
clojure.lang.BigInt
The Java-platform bigint is java.lang.BigInteger which are created with (biginteger) which was added in Clojure 1.0. Printing one of these will not include an N suffix: user=> (biginteger "129110040087761027839616029934664535539337183380513")
129110040087761027839616029934664535539337183380513
user=> (type *1)
java.math.BigInteger
Clojure BigInts are supposed to involve less unboxing and therefore be more performant. If you provide an integer literal that's too large to fit in a java.lang.Long, the reader will use a BigInt instead: user=> 129110040087761027839616029934664535539337183380513
129110040087761027839616029934664535539337183380513N
user=> (type *1)
clojure.lang.BigInt
user=> 12345
12345
user=> (type *1)
java.lang.Long
If all this seems like a mess, well it sort of is. Clojure has a very strong commitment to backwards compatibility, so when the Clojure-specific big int representation was added, the old JDK-based one was not removed, because the operations that the two support are different.The nice ergonomic thing about clojure.math.numeric-tower is you can shove any of the Clojure numeric types at it (longs, doubles, but also Ratio or BigNum etc) and it'll intelligently handle the various combinations of types in order to give you the best answer it can
(map (partial Math/pow 2) [0 1 2 3])This will work: (map (partial #(Math/pow %1 %2) 2) [0 1 2 3])
/pedantic
If your point is that it’s wrong in spirit, I totally agree, and I think this is yet another example of the limits of this “cheat sheet” approach. If you’re coming from another language, the concept of easy, well integrated interop with a host language platform would be fairly foreign, so the importance of an available Java method, and the fact that such methods are frequently used as core parts of the language, would be totally lost on you.
And this is then consistent in ClojureScript as well.