This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

LUA Scientific Conversion loose decimal
#1
Hi,

I'm facing an issue with a POST request and its return value.

I'm sending a POST request to a device and it replay with a payload containing a number.

this number is like:
1000000012345685

LUA automatically converts to scientific notation and shown as 1.00000001234568e+15

the issue cames during its back fortmat to string/number:

string.format('%.0f',1.00000001234568e+15) >> 1000000012345680

AND NOT 1000000012345685.
this invalidate my other function that is supposed to use the right number.

Actually the issue seems to be LUA itself that truncate to 14 decimals
Considering that there is no way to get the POST request as tring, is there a way to:
- Forse LUA to use 15 decimals in autoconversion
- Disable the automatic scientific notation

Thanks
ciao
M
Reply


Messages In This Thread
LUA Scientific Conversion loose decimal - by emme - 09.05.2022, 09:15

Forum Jump: