On Mar 2, 2:05 am, Jason Wolfe <ja...@w01fe.com> wrote: > > But I don't know what the plan is if you really do want truncating > > arithmetic on longs. > > On 1.3 alpha 4: > > user=> (+ Long/MAX_VALUE Long/MAX_VALUE) > ArithmeticException integer overflow > clojure.lang.Numbers.throwIntOverflow (Numbers.java:1581) > > user=> (set! *unchecked-math* true) > true > > user=> (+ Long/MAX_VALUE Long/MAX_VALUE) > -2
Looks good, only it doesn't seem to work for division: (set! *warn-on-reflection* true) (set! *unchecked-math* true) (/ 1 2) Reflection warning, NO_SOURCE_FILE:1 - call to divide can't be resolved. 1/2 What I want in this particular program is a truncating, unchecked division on longs, but there doesn't seem to be any way of getting that using these constructs. Even for ints you need to explicitly call unchecked-divide-int: (/ (int 1) (int 2)) Reflection warning, NO_SOURCE_FILE:1 - call to divide can't be resolved. 1/2 (unchecked-divide-int (int 1) (int 2)) 0 I'm guessing the problem here is that compared to the other unchecked* functions, unchecked-divide-int does two additional things: it gets rid of the fractional results and it truncates the result to int. I can't find any way to do that with longs. ps: I realize that in these examples, I could use a bit-shift. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en