On Mar 5, 10:00 pm, "mike.farn...@gmail.com" <mike.farn...@gmail.com>
wrote:
> I was sort of surprised by this.
>
> user=> (+ (float (* (/ 2) (/ 3))) (float (* (/ 2) (/ 3))) )
> 0.33333334
>
>  (=  (+ (float (* (/ 2) (/ 3))) (float (* (/ 2) (/ 3))) ) (/ 3) )
> yields true
>
> How is tracking these number internally?
>
> And, why does it present the float version of 1/3,
> as rounded up?

This is a question about floating-point arithmetic, not about
Clojure.  See

http://en.wikipedia.org/wiki/IEEE_754

and

http://docs.sun.com/source/806-3568/ncg_goldberg.html

In particular, note that Java uses binary representation for floating-
point numbers, which probably explains the "rounding up" observation.

mfh
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to