Razii <(E-Mail Removed)> wrote:

> >This is probably why .NET went the "quick" route - because no-one

> >realistically should be dealing with radian values that large in the

> >first place.

>

> We are discussing partialsums benchmark .
The post I was replying to wasn't - it was discussing sin(1e7)

and sin(1e10). This subthread was started with a post talking about

sin(1e15).

I still maintain that if you're using that magnitude of angle in a real

world application, you've got bigger problems. (In the benchmark,

giving a value of N=2500000 means you're still taking the sin of a

ridiculously large angle.)

> Let's change

>

> Console.WriteLine("{0:f9}\tFlint Hills", a4);

>

> to

>

> Console.WriteLine("{0:f16}\tFlint Hills", a4);

>

> and see if even get the same answer.
That's not the best way of finding out the exact value of a double. See

http://pobox.com/~skeet/csharp/floatingpoint.html and download

DoubleConverter.cs. Then you can use DoubleConverter.ToExactString to

find out the absolutely precise value.

> (.NET)

> 30.3145415095625000 Flint Hills

> 42.9952339980839000 Cookson Hills
Using DoubleConverter and N=2500000 I get:

2.999999999999998667732370449812151491641998291015 625 (2/3)^k

3160.81762188707580207847058773040771484375 k^-0.5

0.999999600000204380556567684834590181708335876464 84375 1/k(k+1)

30.31454150956249549153653788380324840545654296875 Flint Hills

42.99523399808393975263243191875517368316650390625 Cookson Hills

15.30901715473919821874915214721113443374633789062 5 Harmonic

1.644933666848367392887553251057397574186325073242 1875 Riemann Zeta

0.693146980560093828316325925698038190603256225585 9375 Alt. Harmonic

0.785398063397435564070292457472532987594604492187 5 Gregory

> (JAVA)

> 30.3145415095632840 Flint Hills

> 42.9952339980842500 Cookson Hills

>

> We don't. C# answer is most likely wrong so "fast" in this benchmark

> comes at the cost of wrong answer.
I love the way you go straight from "most likely" to an absolute

assertion that the speed *is* at the cost of correctness. Note how the

benchmark doesn't provide "correct" values. Heck, the results posted

(in the languages I looked at, which was a fair variety) don't show

enough significant figures to show whether they agree with .NET, Java

or neither.

None of the languages is going to get a perfectly accurate answer, of

course - the accumulated error over 2.5 million additions is likely to

be pretty significant, especially when each of the values added is only

an approximation to the mathematical truth anyway.

Now when a platform starts giving inappropriate answers on *sensible*

questions, that's when I'd get more worried.

--

Jon Skeet - <(E-Mail Removed)>

Web site:

http://www.pobox.com/~skeet
Blog:

http://www.msmvps.com/jon.skeet
C# in Depth:

http://csharpindepth.com