you may want to check how the floats and doubles are stored into memory using ieee notation.
i tried to print 0.08 and 0.08f in hex format and got the following result. vishal@ubuntu:~/progs/c\ 10:03:56 AM >$ cat fl.c #include <stdio.h> int main() { float f=0.08; if (f < 0.08f) printf("hi\n"); else printf("hello\n"); printf ("%x %x\n",0.08, 0.08f); return 0; } vishal@ubuntu:~/progs/c\ 10:04:06 AM >$ gcc fl.c fl.c: In function ‘main’: fl.c:10: warning: format ‘%x’ expects type ‘unsigned int’, but argument 2 has type ‘double’ fl.c:10: warning: format ‘%x’ expects type ‘unsigned int’, but argument 3 has type ‘double’ vishal@ubuntu:~/progs/c\ 10:04:11 AM >$ ./a.out hello 47ae147b 3fb47ae1 vishal@ubuntu:~/progs/c\ 10:04:14 AM >$ ps: please ignore the warning in the code. On Sun, May 29, 2011 at 10:23 PM, sravanreddy001 <sravanreddy...@gmail.com> wrote: > and, I read it long time back that.. the value of 0.8 alone will be stored > as 0.799999999995 (not sure on the number of 9's but.. the last digit in the > precision will be a 5) > that could be a reason. > may be what "vishal" said is correct. > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.