|
-
October 2nd, 2011, 08:32 AM
#10
Re: 0 isn't 0 in C++ math
 Originally Posted by Igor Vartanov
I don't know what's wrong with your code, but mine works fine:
Code:
#include <stdio.h>
int main()
{
float a = -0.1;
printf("%f", a +0.1);
return 0;
}
when add one time its true, but when you do it with cycle it looks something like this
a = -0.1 + 0.01000000001 and so on
and then you compare 0 with a it is looks something like this 0 != 0.0000000000001
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|