Arithmetic Exception in 1.3

35 views
Skip to first unread message

PC

unread,
Sep 19, 2011, 2:44:51 PM9/19/11
to Clojure
I've been experimenting with the numeric capabilities of Clojure and I
encountered this:

Clojure 1.2.1
user=> (apply * (repeat 100 2))
1267650600228229401496703205376

Clojure 1.3.0-RC0
user=> (apply * (repeat 100 2))
ArithmeticException integer overflow
clojure.lang.Numbers.throwIntOverflow (Numbers.java:1374)

Is this really the intended behavior for version 1.3?

Herwig Hochleitner

unread,
Sep 20, 2011, 8:43:30 AM9/20/11
to clo...@googlegroups.com
2011/9/19 PC <pca...@gmail.com>:

> (apply * (repeat 100 2))
Auto promotion has been turned off in favor of performance. Operations
with auto-promoting behavior are available as primed functions.
Try (apply *' (repeat 100 2))

also see http://dev.clojure.org/display/doc/Documentation+for+1.3+Numerics

kind regards
--
__________________________________________________________________
Herwig Hochleitner

Aaron Cohen

unread,
Sep 20, 2011, 11:22:04 AM9/20/11
to clo...@googlegroups.com
Alternatively: (apply * (repeat 100 2N)) and allow "BigInt contagion" to work.


--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

PC

unread,
Sep 21, 2011, 10:01:27 PM9/21/11
to clo...@googlegroups.com
I see!  I'll have to go back and read up on these features.

Thanks to everyone!
Reply all
Reply to author
Forward
0 new messages