[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Integers-related trap in Lua 5.3
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Mon, 16 May 2016 11:50:04 -0300
> > print( num( 1,000,000,000,000 ) ) --> 1000000000000.0
> > print( num( 2,012,014,144,567 ) ) --> 2012014144567.0
> > print( num( 1,000,000,000,000,000,000,000 ) ) --> 1e+21
> >
> It should be possible to write a token filter that identifies the
> num() function and transforms the input into a float in scientific
> notation at compile time, to avoid the O(n) runtime overhead.
Indeed, but it'd be safer if num accepted strings only:
num"1,000,000,000,000"
Using this syntax, a token filter is even easier to write.