[Issue 10448] min and max are not NaN aware

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jun 22 13:13:07 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10448


thelastmammoth at gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |thelastmammoth at gmail.com


--- Comment #1 from thelastmammoth at gmail.com 2013-06-22 13:13:06 PDT ---
(In reply to comment #0)
> (and so are probably minCount, minPos, or mostly everything else that is
> related to opCmp).
> 
> From the discussion https://github.com/D-Programming-Language/phobos/pull/1360
> :
> min(0, float.nan); //Yields 0
> max(0, float.nan); //Yields 0
> min(float.nan, 0); //Yields float.nan
> max(float.nan, 0); //Yields float.nan
> 
> Not sure what the correct solution is: Throwing an exception on NaN might be
> too expensive? How about an assert, combined with an explicit: "Passing nan is
> an ERROR", and let the user decide if/ifnot to pay for the check?

I don't see why one would throw on nan, and it would be expensive.
I believe the accepted convention is that nan is treated as missing data for
min/max, so that 
min(0, float.nan); //Yields 0
max(0, float.nan); //Yields 0
min(float.nan, 0); //Yields 0
max(float.nan, 0); //Yields 0

related discussion:
http://bytes.com/topic/c/answers/528404-max-nan-0-should-nan
matlab does it that way btw.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list