On Thu, 14 Oct 2021 at 16:21, frijolithedog 1 via Gcc-help < gcc-help@xxxxxxxxxxx> wrote: > I am having a C programing problem where <= is interpreted as < when using > GCC 11.2.0 > > I was debugging a larger program which I broke down into smaller sections > of code and I noticed > the following code was not working correctly: > > #include <stdio.h> > #include <math.h> > #include <float.h> > > int main(void) > { > float n, step; > > step = 0.1; > > for (n = 2; n <= 10; n = n + step ) > printf("%3.4f\n", n ); /* This stops at > 9.9000 and not at 10.0000 */ > > } > > I tried the above code only using the following include statement > #include <stdio.h> > but the result was the same. > See https://stackoverflow.com/questions/21895756/why-are-floating-point-numbers-inaccurate and hundreds of other pages explaining the properties of floating-point numbers: https://docs.python.org/3/tutorial/floatingpoint.html https://en.wikipedia.org/wiki/Floating-point_arithmetic#Representable_numbers,_conversion_and_rounding For the full story: https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html