Page 1 of 1

Negative Floating point overflow

Posted: Thu Feb 15, 2018 3:54 pm
by rob_fox_cermag
What is the range of a floating point value on the ESP32, using the Arduino IDE?

I get an overflow if I have a value below zero, which I do not get if I compile the same code for a Nano for example.

Re: Negative Floating point overflow

Posted: Thu Feb 15, 2018 11:05 pm
by ESP_Angus
That doesn't sound quite right. 32-bit floats on ESP32 are IEEE754 single-precision format, so should include a lot of values below zero (down to very large negative numbers.)

Can you please post some code which exhibits this problem on ESP32 and not on other platforms?

Re: Negative Floating point overflow

Posted: Fri Feb 16, 2018 12:19 pm
by rob_fox_cermag
I'm almost too embarrassed to reply, but, I was using a float which had a value assigned by a calculation which had an unsigned int as part of the equation. For some reason the Arduino Nano just dealt with this, but the ESP32 didn't.

Anyway, I've cast the unsigned int to a float in the calculation and it's fine now.

Silly mistake, it's the fact that it worked on the Nano that threw me.

Re: Negative Floating point overflow

Posted: Fri Feb 16, 2018 4:24 pm
by tele_player
I’d be curious to see the expression. Type conversion/promotion/coercion is handled in the compiler.