lua-users home
lua-l archive

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


On 23 December 2014 at 11:47, Soni L. <fakedme@gmail.com> wrote:
>
> From http://www.lua.org/manual/5.2/manual.html#pdf-file:read
>
>
> "*n": reads a number; this is the only format that returns a number instead of a string.
>
> How does it "read a number"? Can I make my implementation read an unary number?

Reads a number in the same way `tonumber(mystring)`, coercion, or
anything else in lua does.

See:

http://www.lua.org/manual/5.2/manual.html#3.4.2:
> following the rules of the Lua lexer. (The string may have leading and trailing spaces and a sign.)

http://www.lua.org/manual/5.2/manual.html#3.1:
> A numerical constant can be written with an optional fractional part and an optional decimal exponent, marked by a letter 'e' or 'E'.
> Lua also accepts hexadecimal constants, which start with 0x or 0X.
> Hexadecimal constants also accept an optional fractional part plus an optional binary exponent, marked by a letter 'p' or 'P'