There are four separate methods called Math/abs, to handle the following types: int, long, float, double. So when you use Math/abs on a different Number type, it is not clear which of those methods it should use.
The other examples you gave can only accept double. Maybe in that case Clojure is automatically converting to double. It seems like it would be an improvement if ratios had a preference order for what they could be cast into, in which double is preferable to float is preferable to long is preferable to int. On the other hand, java.lang.Math should really only be used when you want fast primitive operations. If you want better support for Clojure numeric types, try clojure.contrib.math. http://richhickey.github.com/clojure-contrib/math-api.html On Sun, Nov 14, 2010 at 6:46 AM, Jarl Haggerty <fictivela...@gmail.com> wrote: > Math/abs won't accept ratios, so I assumed the Java Math functions > only took base number types but all the other methods I tried accept > ratios just fine. > > user=> (Math/sin 1/2) > 0.479425538604203 > user=> (Math/sqrt 1/2) > 0.7071067811865476 > user=> (Math/pow 1/2 1/2) > 0.7071067811865476 > user=> (Math/abs 1/2) > IllegalArgumentException No matching method found: abs > clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:77) > > -- > 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 -- 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