Note that using the auto-promoting ops will automatically overflow into an 
arbitrary precision type:

user=> (*' 3037000500 3037000500)
9223372037000250000N
user=> (*' 100000000000 100000000000)
10000000000000000000000N

The trailing N indicates the arbitrary precision integer.

On Friday, March 3, 2017 at 10:56:43 AM UTC-6, [email protected] wrote:
>
> On 03/03/2017 12:14 AM, BongHyeon. Jo wrote: 
> > (unchecked-multiply 100000000000 100000000000) 
>
> The default type clojure uses for integers is the jvm's long (or the 
> boxed variant Long) type. Longs are signed 64bit numbers. 
> 10000000000000000000000 is outside the range of longs. 
> `(* 100000000000 100000000000)` will throw an error because of the 
> overflow. `(*' 100000000000 100000000000)` will promote the result to a 
> BigInt (most ops have a primed variant that auto promotes). The 
> `unchecked` in `unchecked-multiply` means it doesn't check the result, 
> so overflow silently happens, as you have seen. The `unchecked` variants 
> are intended for use when you are sure overflow is ok and you want the 
> fastest possible math. 
>
> -- 
> And what is good, Phaedrus, 
> And what is not good— 
> Need we ask anyone to tell us these things? 
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to