Math problem in ESP32?
Posted: Sat Jun 29, 2024 9:46 pm
Hello. Why when performing the following mathematical operation with float, the result is -0.0?
I don't make sense of the "-" sign. Is it a bug?
In the following code you can see the result:
The result is -0.00
I don't make sense of the "-" sign. Is it a bug?
In the following code you can see the result:
Code: Select all
float val1 = -0.1;
float val2;
void setup(){
Serial.begin(115200);
}
void loop(){
val2 = val1 + 0.1;
Serial.println(val2);
}