www.digitalmars.com         C & C++   DMDScript  

D - [Bug?] dmd floating point precision

reply Manfred Nowak <svv1999 hotmail.com> writes:
One of the results in the thread "[Performance] dmd outperforms gcc C and
several others in trigonometric functions" is that dmd is slow in long
arithmetic.

One result I did not mention there: the output of the double arithmetic
differs from gcc to dmd. I once read that the output of floating point
operations is defined to the bit. If true, then the question is which of
both is buggy.

To have some ground to this I have run a bc script with scale set to
thirty for some hours. The outputs:

gcc: 10011632717.388229
dmd: 10011632717.505636
bc : 10011632717.40994285037819773240630676856

Needless to say, that the output from dmc is the same as that from dmd.

The maximal error for a single fp operation for numbers in this magnitude
is in the order of 2.22302903141305656980e-06.

Comments?

So long.
Mar 12 2004
next sibling parent reply C <dont respond.com> writes:
Do you have a site where your posting the results of these tests ?

C

On Sat, 13 Mar 2004 01:03:26 +0100, Manfred Nowak <svv1999 hotmail.com> =

wrote:

 One of the results in the thread "[Performance] dmd outperforms gcc C =

 several others in trigonometric functions" is that dmd is slow in long=

 arithmetic.

 One result I did not mention there: the output of the double arithmeti=

 differs from gcc to dmd. I once read that the output of floating point=

 operations is defined to the bit. If true, then the question is which =

 both is buggy.

 To have some ground to this I have run a bc script with scale set to
 thirty for some hours. The outputs:

 gcc: 10011632717.388229
 dmd: 10011632717.505636
 bc : 10011632717.40994285037819773240630676856

 Needless to say, that the output from dmc is the same as that from dmd=

 The maximal error for a single fp operation for numbers in this magnit=

 is in the order of 2.22302903141305656980e-06.

 Comments?

 So long.

-- = Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Mar 12 2004
parent Manfred Nowak <svv1999 hotmail.com> writes:
C wrote:

 Do you have a site where your posting the results of these tests ?

No. I do not want neither, not disqualify dmd in the public nor attract customers to M$. So long!
Mar 13 2004
prev sibling next sibling parent reply "Walter" <walter digitalmars.com> writes:
There could be many reasons for the differences. Without seeing the code,
there's no way to tell.

"Manfred Nowak" <svv1999 hotmail.com> wrote in message
news:c2tjre$2ve5$1 digitaldaemon.com...
 One of the results in the thread "[Performance] dmd outperforms gcc C and
 several others in trigonometric functions" is that dmd is slow in long
 arithmetic.

 One result I did not mention there: the output of the double arithmetic
 differs from gcc to dmd. I once read that the output of floating point
 operations is defined to the bit. If true, then the question is which of
 both is buggy.

 To have some ground to this I have run a bc script with scale set to
 thirty for some hours. The outputs:

 gcc: 10011632717.388229
 dmd: 10011632717.505636
 bc : 10011632717.40994285037819773240630676856

 Needless to say, that the output from dmc is the same as that from dmd.

 The maximal error for a single fp operation for numbers in this magnitude
 is in the order of 2.22302903141305656980e-06.

 Comments?

 So long.

Mar 12 2004
parent Manfred Nowak <svv1999 hotmail.com> writes:
Walter wrote:

 There could be many reasons for the differences. Without seeing the code,
 there's no way to tell.

Because of the copyright of the code here is the link again: http://www.ocf.berkeley.edu/~cowell/research/benchmark/code/ The adaption D is straight forward, if needed at all. So long!
Mar 13 2004
prev sibling parent reply "Walter" <walter digitalmars.com> writes:
"Manfred Nowak" <svv1999 hotmail.com> wrote in message
news:c2tjre$2ve5$1 digitaldaemon.com...
 One of the results in the thread "[Performance] dmd outperforms gcc C and
 several others in trigonometric functions" is that dmd is slow in long
 arithmetic.

 One result I did not mention there: the output of the double arithmetic
 differs from gcc to dmd. I once read that the output of floating point
 operations is defined to the bit. If true, then the question is which of
 both is buggy.

 To have some ground to this I have run a bc script with scale set to
 thirty for some hours. The outputs:

 gcc: 10011632717.388229
 dmd: 10011632717.505636
 bc : 10011632717.40994285037819773240630676856

 Needless to say, that the output from dmc is the same as that from dmd.

 The maximal error for a single fp operation for numbers in this magnitude
 is in the order of 2.22302903141305656980e-06.

 Comments?

The results differ likely because of how long the 80 bit temporaries are kept around. If you do it with long doubles, the answer comes pretty close to the bc one.
Mar 21 2004
parent reply Manfred Nowak <svv1999 hotmail.com> writes:
Walter wrote:

[...]
 gcc: 10011632717.388229
 dmd: 10011632717.505636
 bc : 10011632717.40994285037819773240630676856

kept around.

This answer implies that gcc is somehow better suited to problems that fall into the same category. So long!
Mar 21 2004
parent "Walter" <walter digitalmars.com> writes:
"Manfred Nowak" <svv1999 hotmail.com> wrote in message
news:c3llth$qgd$2 digitaldaemon.com...
 Walter wrote:

 [...]
 gcc: 10011632717.388229
 dmd: 10011632717.505636
 bc : 10011632717.40994285037819773240630676856

kept around.

This answer implies that gcc is somehow better suited to problems that fall into the same category.

The "somehow" could be little more than a random side effect, not something to be relied on. If you want to rely on better precision, use long double instead of double.
Mar 22 2004