Hi, I've been trying out Racket for 2D graphics tasks and have come across the Racket math library. Firstly just wanted to say a big thank you to the developers for such a well thought out and documented library.
I've had problems in the past with floating point comparison, especially around "catastrophic cancellation" issues. What I need as a result is a "tunable" floating point (Flonum) comparison function. Following these authors: http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm https://www.ualberta.ca/~kbeach/phys420_580_2010/docs/ACM-Goldberg.pdf http://stackoverflow.com/questions/10334688/how-dangerous-is-it-to-compare-floating-point-values/10335601#10335601 I've been testing this approach that provides an "epsilon" value for two flonums near zero and an ULP difference otherwise. (: close? (-> Flonum Flonum Real Real Boolean)) (define (close? x y eps ulps) (cond [(or (nan? x) (nan? y)) #f] [(<= (abs (- x y)) (fl eps) #t] [(not (= (sgn x) (sgn y))) #f] [else (<= (flulp-error x y) (fl ulps))])) I'm almost certainly misunderstanding something in those references and not making the best use of the facilities the math library has to offer. Has anyone else gone down this path with Racket and can share their experiences? Thanks, Stu -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.