This is a static archive of our old Q&A Site. Please post any new questions and answers at

add error with bignumbers in lua


Hi guys, i have a problems doing the operation add with numbers of 64 bits

the following code return a incorrect value:

report_failure(string.format("%16x", ((0xfefefefe * math.pow(2,32))+0xabababab)))

this code should be return a window with the value fefefefeabababab, but return fefefefeababa800

any idea?

asked 27 Nov '13, 06:24

Javier%20Aguinaga's gravatar image

Javier Aguinaga
accept rate: 0%

edited 27 Nov '13, 06:34

One Answer:


Lua stores all numbers (internally) as floats (by default double-precision floating point numbers). So you can't do 64-bit math very well in Lua. For some more details see this email on the wireshark-users mailing list.

answered 27 Nov '13, 11:25

JeffMorriss's gravatar image

JeffMorriss ♦
accept rate: 27%

thanks, i'll see the links

(27 Nov '13, 12:00) Javier Aguinaga