beark / ftl

C++ template library for fans of functional programming
zlib License
992 stars 69 forks source link

The fequal function #19

Open ghost opened 8 years ago

ghost commented 8 years ago

It was added for the unit tests. Are you sure that function doesn't return true for any pair of inputs >= 1.0f? Some quick experiments showed me that it does.

http://coliru.stacked-crooked.com/a/4b8e59043bdaf273

Asking since I've seen it being used with floats >= 1.0f, for example:

fequal((unary % binary)(2,2), 8)

within functional_tests.cpp, line 59. If the above is true, that line passes due to coincidence.

Any reason why the float comparison isn't something like a check for abs(x - y) < epsilon?

beark commented 8 years ago

You may indeed be right. Honestly, I didn't add it, it was some pull request a long time ago. I obviously didn't pay enough attention. Feel free to submit one yourself, if you want. Otherwise it's probably going to take me a while to get around to I'm afraid.

ghost commented 8 years ago

I'll give it a shot once I get to a compiler I can work with.