I asked myself what are the differences between integer and float firmware and how to deal with them. All I managed to find was:
an integer version that supports only whole operations and a float version that contains support for floating point calculations
Ok, so good, but wat does that mean in real life?
What happens when I calculate
a = 3/2
For the floating point version, I would expect = 1.5. For the integer version, would I expect a = 1. Or would it be 2 or would it cause an error or crash or something else? I know, I could just run the integer version and try, but I would like to discuss it answered here. :)
What other limitations / differences are there? The main reason I ask: I tried to run some scripts on the integer version without any floating-point operations that I know of, and some functions just don't exist. With a floating version, it works as expected.
Update:
Here is a snippet that produces an unexpected result:
local duration = (now - eventStart)
duration - 0 with the whole firmware. I think this is because now eventStart is too big for an integer:
now: 1477651622514913 eventStart: 1477651619238587
Therefore, I would say that other limitations are that the integer version only supports whole operations with 31-bit values, because when I convert
now = tonumber(now)
now = 2147483647, which is 2 ^ 31 - 1
therefore in integer firmware
1477651622514913 - 1477651619238587 = 0
coincides with
2147483647 - 2147483647
which is obviously 0
nodemcu
Michi kaa
source share