lua-users home
lua-l archive

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

Hi all,

I wrote my own Lua-crc function and got some weired results. For
proofing correctness I also implemented a c-program.
But when the c-program returned a negative value (with %d) I got a
different value from the Lua-library.

My algorithm is quite similar to the one from lash-lua:

Although I got the data with the luaL_checkinteger()-function.
Seems that there lies the problem, but I don't get what I've done wrong.
Inside Lua every number is a floating-point. So when I call my library
function from a Lua-script I pass the value converting it to a number.
Therefore a floatingpoint number should be on the stack and I "cast "
it into my c- integer variable with the check integer-function.
But representation of integer-values shouldn't be a problem
In the c-program I pass the value via atoi()-function call from argv[]
which shouldn't be a problem, too.

Can anyone give me a hint, what I am missing.