cancel
Showing results for
Did you mean:
cancel
Showing results for
Did you mean:

16-Pearl

## Inconsistent NaNs

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

7 REPLIES 7
19-Tanzanite
(To:AlanStevens)
 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 III
(To:AlanStevens)

I think an error message is here the correct answer.

24-Ruby III
(To:ValeryOchkov)

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

19-Tanzanite
(To:AlanStevens)
 I think it is sometimes possible to mix NaNs and numbers sensibly

True. Since we are not allowed to have an empty placeholder a NaN is often used to represent a missing value. The same could then be said for mixtures of naNs and strings (a NaN then represents a missing string, which is not the same as an empty string).

16-Pearl
(To:RichardJ)
 ... a NaN then represents a missing string, which is not the same as an empty string.

Perhaps we should have a NaS for this case i.e. Not a String!

Alan

4-Participant
(To:RichardJ)

Interesting point on the empty spaceholder. One of the biggest problems I have with Mathcad is the lack of a NULL-value. Using webcontrols leaving an text field empty is equalled by Mathcad as a value of 0.

I have situations where I do need a distinction between NULL (empty) and the value of 0. It could seem odd, but to me NULL and 0 are different values, having a different behaviour.

Having a NULL-value could also solve the problems regarding inconsistent NaN's. NaN could then be the result of incompatible operations on data, while NULL is the result of an empty/undefined value somewhere along the input and calculation sequence.

I would make my life a lot easier... I do not use NaN to replace a missing value as I've also encountered situations where functions are not performing as expected. Instead I use 0, but that creates other problems because of the webcontrol behaviour (for instance what do you do when you try to override a calculated value with 0 without additional input like checkboxes...).

So PTC has to add a NULL-value, or re-evaluate all functions on the behaviour with NaN as a variable. My preference goes to the first option as it enables the user to identify the source of the problem (missing input or incompatible calculations).

Announcements