Hey Does the part about numbers: http://clojure.org/data_structures clear it up for you?
>From (source +) you should see that (+ 0.1 0.1M ...) is matched to (. clojure.lang.Numbers (add x y))) ; (. clojure.lang.Numbers (add 0.1 0.1M)) =>0.2 and that (+ 0.1M 0.1M ...) is (. clojure.lang.Numbers (add 0.1M 0.1M)) =>0.2M So maybe the contagious nature of numbers are biting somewhere - you should experiment around. [(+ 0.9 0.1) (+ 0.8 0.1) (+ 0.7 0.1)] [(+ 0.9 0.1M) (+ 0.8 0.1M) (+ 0.7 0.1M)] [(+ 0.9M 0.1) (+ 0.8M 0.1) (+ 0.7M 0.1)] [(+ 0.9M 0.1M) (+ 0.8M 0.1M) (+ 0.7M 0.1M)] https://en.wikipedia.org/wiki/Arithmetic_precision /Kevin On Mon, Jul 30, 2012 at 5:04 PM, grahamke <kgraha...@gmail.com> wrote: > I was testing some of the code in Miclael Fogus & Chris Houser's The Joy of > Clojure and found this: > > Clojure 1.4.0 > user=> (let [a (+ 0.1 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M)] > (println (class a)) > a) > java.lang.Double > 0.9999999999999999 > user=> (let [b (+ 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1)] > (println (class b)) > b) > java.lang.Double > 1.0 > user=> > > Can anyone help by explaining why a and b are not equal? I figure it has > something to do with the reduce1 function. > > Thanks! > > -Kevin > > -- > 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