Conditional using a float that is "-0" and how that works
hi,
i have float called currentdblevel varies between -100 , 0 , incremented based on input encoder. there conditionals things based on floats value 1 of them doesn't seem want , i'm not sure why. i've simplified of code show here.
this code produces output:
so why currentdblevel test smaller max_dblevel? when print them same? missing something?
i have float called currentdblevel varies between -100 , 0 , incremented based on input encoder. there conditionals things based on floats value 1 of them doesn't seem want , i'm not sure why. i've simplified of code show here.
code: [select]
float currentdblevel;
float max_dblevel = -0.0001;
if (currentdblevel < max_dblevel) {
serial.print (" yes ");
serial.print (currentdblevel);
serial.print (" < ");
serial.print (max_dblevel);
serial.print (" /// ");
}
this code produces output:
code: [select]
currentdblevel: -1.00
currentdblevel: -0.00
yes -0.00 < -0.00 ///
so why currentdblevel test smaller max_dblevel? when print them same? missing something?
try:
serial.print(currentdblevel,6);
are numbers same @ 6dp? or have been rounded print function.
serial.print(currentdblevel,6);
are numbers same @ 6dp? or have been rounded print function.
Arduino Forum > Using Arduino > Programming Questions > Conditional using a float that is "-0" and how that works
arduino
Comments
Post a Comment