7 msgRFC: Creating a live, all-encompassing architec...
53 msgGCC 4.3 release schedule
4 msgAutovectorized HIRLAM - latest results.
5 msgHow widely used are <ext/hash_set> and &l...
1 msgGCC 4.3.0 Status Report (2007-10-25)
3 msgproblem with iv folding
2 msgAny Ada changes for GCC 4.3?
10 msgalias and pointers analysis

Decimal question and sqrt in math.h
\ miha (25 Oct 2007)
. \ Andrew Pinski (25 Oct 2007)
. \ Tim Prince (25 Oct 2007)

54 msg-fno-tree-cselim not working?
5 msglicense for libgcc source files
1 msggcc-4.2-20071024 is now available
16 msgcannot pass objects of non-POD type
4 msgA question about df
2 msgRTL/VCG inconsistency (the check_match.7758 case)
3 msghelp in deciphering a call RTL instruction
3 msgregister variables: list?
1 msgIs peephole2 expansion recursive?
1 msg[RFC PING] INSN attribute to enable/disable alt...
2 msgProblem when build glibc on IA64
Subject:Decimal question and sqrt in math.h
Group:Gcc
From:miha
Date:25 Oct 2007


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




© 2004-2008 readlist.com