This discussion may help:
http://www.gettingclojure.com/cookbook:numbers#comparing-floats

Have all good days,
David Sletten

On Oct 12, 2010, at 12:17 PM, cej38 wrote:

> I keep running into this type of problem:
> 
> user=> (- 12.305 12.3049)
> 9.999999999976694E-5
> 
> The computer (probably the JVM) has just lied to me.  Any fourth grade
> student will know that this does not equal 0.0001.  This would be less
> of a problem is the JVM was consistent; if it were consistent then the
> following equality would be true:
> 
> user=> (= 0.0001 (- 12.305 12.3049))
> false
> 
> Now it has lied to me again!
> 
> I need a method to reliably compare two numbers.  My first choice
> would be to have the JVM compute (- 12.305 12.3049) correctly.
> Barring that, I need a way to, without fail, compute the truthfulness
> of the following: =, <, >, <=, >=.
> 
> -- 
> 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

Reply via email to