Hacker News new | ask | show | jobs
by dllthomas 2228 days ago
> Going back to our integer being a subtype of real number example, the "<" operator will work perfectly fine whether any of the operands are either an integer or a real number.

If we're talking about theoretical "real numbers", then in constructive mathematics I believe "<" isn't decidable on reals. Whether that matters for the point you're trying to make, I have no idea.

If we're talking about floats, we have a concrete example of weird behavior of "<" leading to programming error: in Haskell, you can make a Set of any type that supports "<" (by virtue of being an instance of Ord - things that can be ordered). However, following ieee754, NaN is not equal to NaN. Which means that you can wind up accumulating arbitrarily many copies of NaN in your Set. (You don't usually want to be comparing floats for equality anyway, but it's still not good behavior.)

1 comments

Interesting to hear about "<" is not decidable on reals.

I'm naive, and I'm curious to know where I can read more about that.

Edit: OK, now I get it. Equality/inequality verification is undecidable for irrational numbers.