lua-users home
lua-l archive

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


In this case, I would reference IEEE 754 when 'float number' type is first introduced in section 2.1. I would then remove the reference to NaN from section 3.4.4. That leaves the issue of NaN not being a valid table key. Why not given it is a unique bit pattern in the IEEE 754 code space? But if it is necessary to specifically exclude it, I would refer to it as "the float number value NaN", or "the IEEE 754 value NaN".

Presumably IEEE 754 positive and negative infinity ARE valid table keys, since they are not specifically excluded? What about positive and negative zero? Would these be distinguished table keys?

The problem I had reading section 2.1 is that it implies 'NaN' is something like 'nil' (which as already been introduced) and never explains that it is actually a specific value of the float subtype of the number type.

------ Original Message ------
From: "Egor Skriptunoff" <egor.skriptunoff@gmail.com>
To: "John Hind" <john.hind@zen.co.uk>; "Lua mailing list" <lua-l@lists.lua.org>
Sent: 23/06/2017 16:15:26
Subject: Re: NaN in Lua 5.3 Reference Manual

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'.