I am trying to solving pythonchallenge problem using Clojure:
(java.lang.Math/pow 2 38)
I got
2.74877906944E11
However, I need to turn off this scientific notation. I searched clojure docs, still don't know what to do. Is there a general way to toggle on/off scientific notation in Clojure?
Thanks.
You can use format to control how results are printed.
user> (format "%.0f" (Math/pow 2 38))
"274877906944"
Also, if there is no danger of losing wanted data, you can cast to an exact type:
user> 274877906944.0
2.74877906944E11
user> (long 274877906944.0)
274877906944
There are BigInts for larger inputs
user> (bigint 27487790694400000000.0)
27487790694400000000N
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With