Skip to content

min / max do not always return the other argument when one of the arguments is NaN

I assume that this is well-known, but it tripped me up:

Prelude> let inf = 1/0
Prelude> let nan = 0/0
Prelude> min nan  inf
Infinity
Prelude> min inf nan
NaN
Prelude> min 3 nan
NaN
Prelude> min nan 3
3.0
Prelude> max nan inf
NaN
Prelude> max inf nan
Infinity
Prelude> max 3 nan
3.0
Prelude> max nan 3
NaN
Trac metadata
Trac field Value
Version 7.8.3
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Prelude
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Edited by jrp2014
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information