Negative numbers in IF - statement

Started by Mikael Karstikko November 17, 2005
Hello All !

Once again I am at a loss ...
My pressure sensor fluctuates a little so the display shows 0.0 and -0.0
The display should show numbers between -1.0 to 6.0 bars ... but not
the value -0.0 whitch flickers annoyngly ..
Why doesn't this work ??
Dim pres as single

Do

Call getadc(20, pres)
pres = ((pres - 2.528) / 0.02119) ' convert to pressure

If pres < 0.0 then 'this is my nonworking bypass of value -0.0
If pres < -0.1 then ' and I have tried changing this to (-0.1) ..
no effect
pres = 0.0
End If
End If Call putqueuestr(lcd_out, fmt(pres, 1)) ' here it is displayed on the LCD-X

Loop Thank You All for Your help regarding my previous problems !!


--- In basicx@basi..., Mikael Karstikko <makarst@p...> wrote:
What happens of your pressure is between -0.1 and 0?

Like, what if it is -0.05?

In the code you gave this value would not be changed.

Maybe you meant in the second if-then.... if pres >-0.1 then.....

This would zero out all the barely negative numbers.

Remember, less than means "to the left of" on the number line.

Otherwise use ABS() to get rid of the sign.

-Tony