lua-users home
lua-l archive

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


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