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);
}
Code: Select all
float val1 = -0.1;
float val2;
void setup(){
Serial.begin(115200);
}
void loop(){
val2 = val1 + 0.1;
Serial.println(val2);
}
OK. Thanks for your reply.ESP_Sprite wrote: ↑Mon Jul 01, 2024 9:07 amFloat numbers are imprecise; probably the result of 0.1 + -0.1 is ever-so-slightly negative because of effectively a binary rounding error. Your print will round that number down to two digits after the decimal, so you get the 'weird' -0.00 result.
Users browsing this forum: No registered users and 14 guests