Re: Decimal question and sqrt in math.h

2007-10-25 Thread Tim Prince
[EMAIL PROTECTED] wrote: > > #include > #include > > int main() > { > printf("\n %1.55f \n", sqrt(3.)); > return 0; > } > > Result: 2 > > Why does this return 2 ?? If you meant to use long double, you should have so specified. Decimal digits beyond 17 aren't significant in

Re: Decimal question and sqrt in math.h

2007-10-25 Thread Andrew Pinski
On 10/25/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Why does this return 2 ?? You should read: http://www.validlab.com/goldberg/paper.pdf which is linked on http://gcc.gnu.org/readings.html . Thanks, Andrew Pinski

Decimal question and sqrt in math.h

2007-10-25 Thread miha
I use Gentoo Linux, Gcc 4.1.1 and Intel Celeron processor. I compiled this file: #include #include int main() { printf("\n %1.55f \n", sqrt(3.999)); return 0; } I get 1.999777955395074968691915273666381835 9375000 If you add one more 9 to sqrt you get 2. #include #