Ah - I didn't realise that. I was trying to avoid the overhead, as I understood it, of both converting the parameters to Float/Double objects, and then of checking for overflow.
So '*' and '+' don't do overflow checking - do they need to convert primitives to/from objects? Specifically, when I call: (loop [x (double x) y (double y)] ... do maths to x and y (recur x y) ) Is it going to have to convert x and y between 'double' and 'Double' at all, or will it just work with primitive types??? - Korny On Sat, Feb 7, 2009 at 6:29 PM, Mark H. <mark.hoem...@gmail.com> wrote: > > On Feb 6, 7:14 pm, Korny Sietsma <ko...@sietsma.com> wrote: >> Hi folks - I was trying the example posted below, and I discovered a >> slight snag - unchecked-* methods don't exist for doubles or floats! >> (and if you call (unchecked-multiply 1.2 3.4) you get "No matching >> method found"... which caused some confusion :) ) >> >> Is this something that might change in the future? Or would it be >> easy for a clojure newbie to implement them himself? :-} > > The question is whether it makes sense to have "unchecked_*" methods > for floats and doubles. The point of "unchecked_*" methods is to > declare your willingness to get nonsense answers with fixed-width > integer operations. Floating-point operations already have semantics > that make sense for conditions like overflow, and (unlike integer > operations in Clojure) they don't switch to "bigfloats" on overflow. > > If you'd like to have the methods just for completeness' sake, it > doesn't look too hard to add them. Check out src/jvm/clojure/lang/ > Numbers.java and look for static methods of the form "unchecked_add", > "unchecked_multiply", etc. For each "unchecked_*" method name and for > each data type, there should be one such method: e.g., > > static public int unchecked_add(int x, int y){ > return x + y; > } > > static public long unchecked_add(long x, long y){ > return x + y; > } > > mfh > > > -- Kornelis Sietsma korny at my surname dot com kornys on gmail, twitter, facebook, etc. "Every jumbled pile of person has a thinking part that wonders what the part that isn't thinking isn't thinking of" --~--~---------~--~----~------------~-------~--~----~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---