This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Decimal question and sqrt in math.h
- From: miha at gigabox dot org
- To: gcc at gnu dot org
- Date: Thu, 25 Oct 2007 12:13:57 +0200 (CEST)
- Subject: Decimal question and sqrt in math.h
I use Gentoo Linux, Gcc 4.1.1 and Intel Celeron processor.
I compiled this file:
#include <stdio.h>
#include <math.h>
int main()
{
printf("\n %1.55f \n", sqrt(3.999999999999999));
return 0;
}
I get 1.999999999999999777955395074968691915273666381835 9375000
If you add one more 9 to sqrt you get 2.
#include <stdio.h>
#include <math.h>
int main()
{
printf("\n %1.55f \n", sqrt(3.9999999999999999));
return 0;
}
Result: 2
Why does this return 2 ??
Miha Svalina