Skip to main content
19-Tanzanite
June 11, 2012
Question

Inconsistent NaNs

  • June 11, 2012
  • 2 replies
  • 2135 views

NaNPic.PNG

Some inconsistency here that should be rectified (same in M15).

Only the last is correct in my view, as the function should ignore "numbers" that aren't numbers!

Alan

2 replies

19-Tanzanite
June 11, 2012
Only the last is correct in my view, as the function should ignore "numbers" that aren't numbers!

Either that, or return "NaN". After all, what's the minimum of a string, a scalar, and a NaN? It's a meaningless question. The minimum of any combination of scalars and arrays should be the minimum scalar in all of them. The minimum string should the first string when alphabetically sorted. But the minimum of any combination of numbers, strings, and NaNs is undefined.

24-Ruby IV
June 12, 2012

I think an error message is here the correct answer.

24-Ruby IV
June 12, 2012

And what is your and Mathcad answer here min(NaN)?

19-Tanzanite
June 12, 2012

Valery Ochkov wrote:

And what is your and Mathcad answer here min(NaN)?

Personally, I would return NaN for the minimum of a set of NaN's. I would return an error message for a set of NaN's, numbers and strings etc, because clearly there's been some cock-up if someone is trying to find the minimum of such a combination. I think it is sometimes possible to mix NaNs and numbers sensibly, which is why I'd return the minimum proper number in such a set. However, my main point is that, whatever convention is adopted, it should be consistent - that is, all forms of the function should return the same thing.

Alan