Michele Sardone

Comparison between floats and constants doesn't work, CW10

Discussion created by Michele Sardone on Nov 5, 2010
Latest reply on Nov 29, 2010 by Daniel Lundin


I've come across this problem writing code for MC9s08QE128 MCU: if i want to test a float to be greater than zero and write something like this:



double a;a = -150.1;if(a>0) {    //do action 1;} else {  //do action 2;} ....



well, it does ACTION 1 !! how can it be ?

I' have also tried






if (a>(double)0)... but it doesnt work ! Strange thing is that instead



double a;a = -150.1;if(a>0.1) {   //do action 1} else {   //do action 2}



works correctly !!!

Am I missing something ? I have got float support on my project (ansifs.lib included) and using small memory model.

Thank You for your help !