Can someone recommend a library that contains a function comparing doubles 
for equality?

This clojure cookbook has a section on comparing floating-point numbers.

http://www.gettingclojure.com/cookbook:numbers

This blog post makes me want to find an implementation by someone who has 
more experience in these matters. Thanks.

http://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/

There is no silver bullet. You have to choose wisely.

   - If you are comparing against zero, then relative epsilons and ULPs 
   based comparisons are usually meaningless. You’ll need to use an absolute 
   epsilon, whose value might be some small multiple of FLT_EPSILON and the 
   inputs to your calculation. Maybe.
   - If you are comparing against a non-zero number then relative epsilons 
   or ULPs based comparisons are probably what you want. You’ll probably want 
   some small multiple of FLT_EPSILON for your relative epsilon, or some small 
   number of ULPs. An absolute epsilon could be used if you knew exactly what 
   number you were comparing against.
   - If you are comparing two arbitrary numbers that could be zero or 
   non-zero then you need the kitchen sink. Good luck and God speed.

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