You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 4696 Reporter: toton Status: closed (set by @xavierleroy on 2009-03-28T17:12:27Z) Resolution: not fixable Priority: normal Severity: major Version: 3.10.0 Category: ~DO NOT USE (was: OCaml general) Related to:#5781 Monitored by:@hcarty@dbuenzli@yakobowski
Bug description
min nan 1.;;
: float = 1.
min 1. nan;;
: float = nan
max nan 1.;;
: float = 1.
max 1. nan;;
All results should be NaN.
(Or at least docs should specify what is the intended behavior.)
The text was updated successfully, but these errors were encountered:
AFAIK IEEE 754-1985 doesn't specify a behaviour for min/max functions.
The recent IEEE 754-2008 [1] introduces minNum and maxNum (see 5.3.1). However when presented with a number and a quiet NaN these functions unconditionnaly return the number. So that would be the opposite of what the reporter proposes.
The documentation of Pervasives says simply:
"any operation with nan as argument returns nan as result"
I thought there is a bug in max & min, because their result depends on order of arguments. For me it is natural to assume that (max a b)=(max b a) if the documentation doesn't say otherwise.
However I understand that it is more important to have fast max & min operations than to handle NaNs in a specific way. So I reported this too hastily as a bug, this might be better seen as "documentation request".
You expected min x NaN = NaN, but as D. Buenzli mentioned, other folks recommend min x NaN = x. In Caml, there is one additional difficulty, namely that min and max apply to composite data structures as well. So, what should be
min (x, NaN) (NaN, y), for example? I don't think a "best" behavior exists in this case, so the current implementation is as good (and as bad) as any other.
Original bug ID: 4696
Reporter: toton
Status: closed (set by @xavierleroy on 2009-03-28T17:12:27Z)
Resolution: not fixable
Priority: normal
Severity: major
Version: 3.10.0
Category: ~DO NOT USE (was: OCaml general)
Related to: #5781
Monitored by: @hcarty @dbuenzli @yakobowski
Bug description
min nan 1.;;
min 1. nan;;
max nan 1.;;
max 1. nan;;
All results should be NaN.
(Or at least docs should specify what is the intended behavior.)
The text was updated successfully, but these errors were encountered: