lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Fri, Jun 23, 2017 at 1:41 PM, John Hind wrote:
one aspect that is still not very well described is NaN. There are three references to it, all tangential. Two state that it is not a valid table key while the third describes its treatment by comparison operators. The thing itself is never properly introduced.

 
Lua does not introduce NaN by itself (and therefore should not describe it in details).
IEEE-754 clearly defines the value "NaN", and Lua manual just refers (implicitly) to that definition.
Should Lua manual also define what "floating point number" is?  What "integer number" is?  What "string" is?  What "character" is?  What "more", "less" and "equal" mean?

 
"Not a Number is a special value used to represent undefined or unrepresentable numerical results, such as 0/0."
can one represent the unrepresentable?

The value NaN (Not a Number) is used to represent a value that does not represent a real number.
So yes, one can "represent unrepresentable" in more wide superset.
In a similar way, mathematicians "count uncountable".

 
Indeed the introduction of two number subtypes 'integer' and 'float' opens up an opportunity for conceptual clarification. 'NaN' could be presented as a third subtype.

NaN shares semantics of arithmetic operations with all floating point numbers, so there is no need for splitting 'float' into 'real', 'NaN' and 'infinity'.