I think Clojure should change to allow (bigdec 3) to succeed. BigDecimal has a valueOf method that accepts a long. It has a constructor that accepts an int. I haven't made a bug report on this yet, but here it is.
Here are another thing that came up during testing of numbers: I think the identity "(inc x) = (+ x 1)" should hold true for all Clojure numbers and the corresponding rule should hold for dec. I've found there are a few cases where they don't: user=> (+ Integer/MAX_VALUE 1) 2147483648 user=> (inc Integer/MAX_VALUE) java.lang.ArithmeticException: integer overflow (NO_SOURCE_FILE:0) user=> (- Integer/MIN_VALUE 1) -2147483649 user=> (dec Integer/MIN_VALUE) java.lang.ArithmeticException: integer overflow (NO_SOURCE_FILE:0) user=> (+ Long/MAX_VALUE 1) 9223372036854775808 user=> (inc Long/MAX_VALUE) -9223372036854775808 user=> (- Long/MIN_VALUE 1) -9223372036854775809 user=> (dec Long/MIN_VALUE) 9223372036854775807 user=> I was also going to request that integer? be true for Shorts and Bytes but I'm pleased to see that change has already been made. Thanks, --Steve On Nov 18, 2008, at 4:46 PM, Jarkko Oranen wrote: > > As stated in the subject line, the last test in numbers.clj > throws an exception because it is trying to cast an integer > into a BigDecimal, which is not possible. > > This is on Mac OS X 10.5.5 with Java 1.5, the exception it fails with > is: > java.lang.IllegalArgumentException: No matching method found: valueOf > > I don't think the exception itself is a bug. It seems coercing > Integers into bigdecimals > is something you're not supposed to do. > > I can't submit a patch as I have no CA, but this would be trivial to > fix eg. by coercing a > double literal instead of an integer literal. > > -- > Jarkko > > --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---