Floats, the true ieee next generation Re: Add Ord Laws to next Haskell Report
Bardur Arantsson
spam at scientician.net
Fri Feb 8 21:54:39 UTC 2019
On 08/02/2019 21.53, Vanessa McHale wrote:
> Wouldn't both versions throw an exception in that case? Am I missing
> something?
Not necessarily, the classic example would be the Binary Search bug
https://thebittheories.com/the-curious-case-of-binary-search-the-famous-bug-that-remained-undetected-for-20-years-973e89fc212
(it could be argued that you really want a *trap* in this case as it
would surface the bug, but I'm just confirming that there *can* be
different behavior.)
Generally: I think it's fine to expect WordNN to do wrap-around
arithmetic (and it does form a proper ring), but IntNN is kind of weird
because there is that edge case[1] of minBound (as Carter mentioned
ITT). IME, usually Word-like types are used for things like crypto, etc.
-- not just when you want to enforce "not negative", but that may just
be my little bubble.
[1] In two's complement which even C++20 is set to mandate!
More information about the Libraries
mailing list