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

add error with bignumbers in lua

0

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
11224
accept rate: 0%

edited 27 Nov '13, 06:34


One Answer:

0

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 ♦
6.2k572
accept rate: 27%

thanks, i'll see the links

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