As I tested, looks like when either of the args are double ie. 1.0 instead of 1 then the code that checks for and shows divide by zero is not reached, which is this code: static public Number divide(Object x, Object y){ Ops yops = ops(y); if(yops.isZero((Number)y)) throw new ArithmeticException("Divide by zero"); return ops(x).combine(yops).divide((Number)x, (Number)y); }
On Tue, Oct 30, 2012 at 3:52 PM, Tim Olsen <t...@brooklynpenguin.com> wrote: > Hello Clojurians. > > Normally by some IEEE floating-point standard, division by 0.0 should > give Infinity (or NaN if the divisor is also 0.0). This is the case > when using primitive doubles in clojure: > > (/ 1.0 0.0) > => Infinity > > And even when using boxed Doubles in java: > > public class BoxedDoubleDivideZero { > > public static void main(String[] args) { > Double a = new Double(4.0); > Double b = new Double(0.0); > > System.out.println(a/b); > } > } > > $ javac BoxedDoubleDivideZero.java > $ java BoxedDoubleDivideZero > Infinity > > But it is not the case when using boxed Doubles in clojure: > > (/ (Double. 1.0) (Double. 0.0)) > ArithmeticException Divide by zero clojure.lang.Numbers.divide > (Numbers.java:156) > > Is this considered a bug or feature? > > Thanks, > Tim > > -- > 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 > -- I may be wrong or incomplete. Please express any corrections / additions, they are encouraged and appreciated. At least one entity is bound to be transformed if you do ;) -- 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