Negative Floating point overflow

rob_fox_cermag
Posts: 2
Joined: Thu Feb 15, 2018 3:45 pm

Negative Floating point overflow

Postby rob_fox_cermag » Thu Feb 15, 2018 3:54 pm

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.

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: Negative Floating point overflow

Postby ESP_Angus » Thu Feb 15, 2018 11:05 pm

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?

rob_fox_cermag
Posts: 2
Joined: Thu Feb 15, 2018 3:45 pm

Re: Negative Floating point overflow

Postby rob_fox_cermag » Fri Feb 16, 2018 12:19 pm

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.

tele_player
Posts: 90
Joined: Sun Jul 02, 2017 3:38 am

Re: Negative Floating point overflow

Postby tele_player » Fri Feb 16, 2018 4:24 pm

I’d be curious to see the expression. Type conversion/promotion/coercion is handled in the compiler.

Who is online

Users browsing this forum: No registered users and 64 guests