See discussions here and here. See reasonable summary of IEEE NaN standard here.
The referenced change returned zero if a negative number was passed to sqrt which mimicked some aspects of a quiet NaN but is almost certainly not the "correct" solution for general purpose computing post 1985 or thereabouts.
A full blown implementation of NaNs with signaling NaNs, quiet NaNs, INF and exceptions sometimes thrown when created and otherwise thrown when used is probably overkill for ash and beyond the desires of most scripters.
I propose, for discussion, the following:
The ASH data type float be allowed to store a special value that is a NaN.
ASH functions will be written to test whether a float is a NaN.
Any computation that results in a NaN will return a NaN but otherwise continue execution.
Any computation that attempts to use a NaN as an operand will throw some kind of exception and script or command interpretation will stop.
The equivalent of float.toString(NaN) will display something reasonable but non-numeric.
The specific operations that will be "allowed" to generate a NaN are division by zero and square root of a negative number. (A quick look at the wiki suggests that ASH and expressions evaluated in ASH do not support the other operations that might logically generate NaNs).
It is believed that this may break some scripts but that is an acceptable consequence of preserving the integrity of ASH math.
Discuss, please.
The referenced change returned zero if a negative number was passed to sqrt which mimicked some aspects of a quiet NaN but is almost certainly not the "correct" solution for general purpose computing post 1985 or thereabouts.
A full blown implementation of NaNs with signaling NaNs, quiet NaNs, INF and exceptions sometimes thrown when created and otherwise thrown when used is probably overkill for ash and beyond the desires of most scripters.
I propose, for discussion, the following:
The ASH data type float be allowed to store a special value that is a NaN.
ASH functions will be written to test whether a float is a NaN.
Any computation that results in a NaN will return a NaN but otherwise continue execution.
Any computation that attempts to use a NaN as an operand will throw some kind of exception and script or command interpretation will stop.
The equivalent of float.toString(NaN) will display something reasonable but non-numeric.
The specific operations that will be "allowed" to generate a NaN are division by zero and square root of a negative number. (A quick look at the wiki suggests that ASH and expressions evaluated in ASH do not support the other operations that might logically generate NaNs).
It is believed that this may break some scripts but that is an acceptable consequence of preserving the integrity of ASH math.
Discuss, please.
Last edited: