Value to never go into negative

Hi. I have a reading from a sensor which is a bit unstable and sometimes it goes into negative and when it will show -0.0 instead of 0.0, which annoys me a bit.

Anyone have a solution for this? :)

Thanks.

Probably. But without code it’s a bit hard. You can try something like

if(value < 0){
  value = 0;
}

or something

Or: x = constrain(x,0,maxValue);

Here is some code, but thanks. Will try it out. :)

float voltageA1Rear= sensorValueA1Rear * (5 / 1024.0);
float barA1Rear= (voltageA1Rear - 0.49) / 4.0 * 10.3421359; 
Serial.println (barA1Rear, 1);

outsider: Or: x = constrain(x,0,maxValue);

This worked for me, thanks. :)