lua-users home
lua-l archive

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


Am 16.05.2016 um 16:50 schröbte Luiz Henrique de Figueiredo:
     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.

No need for a token filter for this syntax. A normal function with memoization should be good enough.

Philipp