I found that even without patching, most functions in
clojure.contrib.math already correctly handle big nums in 1.3:

Handles big nums in 1.3?
abs                Yes
ceil               Yes
exact-integer-sqrt No
expt               No
floor              Yes
gcd                Yes
lcm                Yes
round              No
sqrt               Yes

After patching the code to use +', -', *', inc', and dec', expt
handled big nums correctly as well.  However, exact-integer-sqrt and
round still didn't.

math=> (exact-integer-sqrt 234523454564564565435456456456)
IllegalArgumentException No method in multimethod 'integer-length' for
dispatch value: class clojure.lang.BigInt  clojure.lang.MultiFn.getFn
(MultiFn.java:121)

math=> (round 23450928345029834502983450283405.1)
9223372036854775807

exact-integer-sqrt appears to need the integer-length multi-method to
support the new clojure.lang.BigInt class.  I'm guessing that's also
why round is returning an incorrect result; since there's currently no
case for clojure.lang.BigInt, it's falling through to the default of
using Math/round, leading to truncation.

Just replacing +, -, *, inc, dec with +', -', *', inc', and dec' did
not result in any performance gains.

I didn't want to clutter up this email with my test code, but if
anyone wishes to see the code I used, just let me know.

-- 
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

Reply via email to