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.

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.


Arduino Forum > Using Arduino > Programming Questions > Conditional using a float that is "-0" and how that works


arduino

Comments

Popular posts from this blog

Connecting Raspberry Pi 2 to P10(1R)-V706 LED Dot Matrix - Raspberry Pi Forums

TypeError: <unknown> is not a numpy array - Raspberry Pi Forums

datso and removing imagetitle - Joomla! Forum - community, help and support