lua-users home
lua-l archive

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

In the course of implementing my hybrid int based Lua with
single precision floats, I discovered an interesting problem
with unary minus on constants....

My text/number conversion is a customized version of atof() that
returns a long int if there is no decimal point or exponent in
the text being parsed.

However, the Lua parser takes the preceding "-" and does not
pass it to the numeric conversion routine.

Instead, it passes everything AFTER the "-" and then does the
unary minus as defined for the default arithmetic type.

s=45.678  works fine
s=-45.678 does not due to the above mentioned problem

I should probably bite the bullet and implement a full userdata
type for single precision floats and leave the default math type
as long, but it wold be nice to have a workaround that worked
automagically in the parser...

Cheers, Ralph