Re: std::max and NAN




"peter koch" <peter.koch.larsen@xxxxxxxxx> wrote in message
news:c12d3720-4324-4ede-a074-95afaeaedc15@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Calling std::sort with a
collection of doubles of which at least one is NaN causes undefined
behaviour

will in practice often have an unfortunate result such
as an infinite loop.

can you show an example?
I think #1 is correct, but #2 in practice will not occur for subtle
algorithmical reasons.


.



Relevant Pages

  • Re: test for nan
    ... John Hunter wrote: ... > I have a C extension module that is returning some doubles. ... > doubles get out of range, the numbers print as 'nan'. ... Peter Maas, M+R Infosysteme, D-52070 Aachen, Hubert-Wienen-Str. ...
    (comp.lang.python)
  • Re: equality and null pointers
    ... fundamental meaning of NaN? ... at least when you want to use Doubles as hash table keys. ...
    (comp.lang.java.programmer)
  • Re: Meaning of Double.Epsilon
    ... >> sort an array of doubles (at least with generics, ... > NaN is just for that purpose: If a value is NaN it stays NaN even if used ... like these have to be values that cannot be result of a calculation. ... converting it to an int will throw an ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Infinite loop
    ... infinite loop and I don't quite understand why. ... But because floating point arithmetic on computers is practically never precise, *never* compare floats or doubles with ==, in your case, you would certainly miss your end criterion by some small epsilon and march on through number space. ...
    (comp.lang.c)
  • test for nan
    ... I have a C extension module that is returning some doubles. ... the numbers print as 'nan'. ... John Hunter ...
    (comp.lang.python)

Loading