"Ulrich Eckhardt" <eckha...@satorlaser.com> wrote in message
news:0koq15-qc6.ln1@satorlaser.homedns.org...
Mycroft Holmes wrote:
does the standard say anything about the behaviour of std::min/max does
on
(say, double) NAN?
I don't know the standard, but looking at the documentation for the STL,
it
mentions that '<' for max/min must provide a partial ordering, which
floating point numbers that are NAN simply break.
MSDN mentions that max/min return the first element if neither is
greater/lesser, but I don't know if that's standard.
I guess that you will find more such problems if you try to sort sequences
containing NAN.
well... not quite, that's more predictable, because a sorting algorithm
usually relies consistently on "less" and since all "less" return false,
NANs end up to the left (I'm speaking from a practical point of view -- as a
rule I totally agree with you).
Here you have an extra source of randomness: based on the result of an
(unknown) operator, you choose one argument or the other.
Sorry, but this is simply not correct. Calling std::sort with a
as an infinite loop. If you want to have NaNs in your doubles, you
well-defined.