The Floating-Point Guide - What Every Programmer Should Know About Floating-Point Arithmetic[^]

What Every Computer Scientist Should Know About Floating-Point Arithmetic[^]

In your case this is hidden because you are comparing the single precision floating point variable

`x`

with the double precision constant `1.1`

. The compiler will convert your float variable `x`

to `double`

and then compare it. Because `1.1`

is one of those values that can't be represented exactly, the comparison fails.In your case it might work when comparing with a single precision constant (note the

`f`

postfix):while(x==1.1f)

But you should not rely on that. Instead you should use "epsilon comparison" as described at Comparing Floating Point Numbers, 2012 Edition | Random ASCII[^].