NodeMCU Integer vs. Is Float Firmware Different?

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

+7
nodemcu
source share
2 answers

You yourself answered your own question. The integer version does not support floating point operations and does not allow non-integer numbers.

In the integer version 3/2, there is 1, not 1.5.

I can just run the integer version and try, but I would also like to discuss it. :)

Stack overflow is a Q&A site and therefore not suitable for discussion. To do this, use the NodeMCU forums on esp8266.com.

+2
source share

Developer FAQ NodeMCU says: "Integer assemblies have a smaller flash size and are faster, but integer work also has a number of pitfalls."

You have discovered some of the errors with 32-bit standard line number limits .
I do not know what others may be, individual modules can have their own.

β€œless”: usually around 13kB of difference per user 1.5.4.1 final assembly is only 369- 478kB

" faster ": here is a comparison of operations with integers and floating point , with the source code, if you want to run your own. The difference is likely to be less if the floats are integers.

0
source share

All Articles