Please, help me to solve the problem: <source code> bit Result; float Density; Density = 0.55; if(( Density < 0.54999995) { Result = 0; } else { Result = 1; } While after running this code Result = 0 ?
Insufficient precision! 0.54999995 is pretty damn close to 0.55, isn't it!
0.54999995 == 0.55 - maybe. But why 0.54999995 > 0.55 ?
In the debugger, look at the raw binary representations of these numbers.
why do you float? store the value *100, take care of the decimal point in the presentation. Your program will compact and speed up and you will smile like the cheshire cat. Erik
View all questions in Keil forum