Re: Accuracy of floating point calculations

2019-10-31 Thread Robert M. Münch via Digitalmars-d-learn
On 2019-10-31 16:07:07 +, H. S. Teoh said: Maybe you might be interested in this: https://stackoverflow.com/questions/6769881/emulate-double-using-2-floats Thanks, I know the 2nd mentioned paper. Maybe switch to PPC? :-D Well, our customers don't use PPC Laptops ;-)

Re: Accuracy of floating point calculations

2019-10-31 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Oct 31, 2019 at 09:52:08AM +0100, Robert M. Münch via Digitalmars-d-learn wrote: > On 2019-10-30 15:12:29 +, H. S. Teoh said: [...] > > Do you mean *simulated* 128-bit reals (e.g. with a pair of 64-bit > > doubles), or do you mean actual IEEE 128-bit reals? > > Simulated, because HW

Re: Accuracy of floating point calculations

2019-10-31 Thread Robert M. Münch via Digitalmars-d-learn
On 2019-10-30 15:12:29 +, H. S. Teoh said: It wasn't a wrong *decision* per se, but a wrong *prediction* of where the industry would be headed. Fair point... Walter was expecting that people would move towards higher precision, but what with SSE2 and other such trends, and the general

Re: Accuracy of floating point calculations

2019-10-30 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Oct 30, 2019 at 09:03:49AM +0100, Robert M. Münch via Digitalmars-d-learn wrote: > On 2019-10-29 17:43:47 +, H. S. Teoh said: > > > On Tue, Oct 29, 2019 at 04:54:23PM +, ixid via Digitalmars-d-learn > > wrote: > > > On Tuesday, 29 October 2019 at 16:11:45 UTC, Daniel Kozak

Re: Accuracy of floating point calculations

2019-10-30 Thread berni44 via Digitalmars-d-learn
On Tuesday, 29 October 2019 at 20:15:13 UTC, kinke wrote: Note that there's at least one bugzilla for these float/double math overloads already. For a start, one could simply wrap the corresponding C functions. I guess, that this issue: https://issues.dlang.org/show_bug.cgi?id=20206 boils

Re: Accuracy of floating point calculations

2019-10-30 Thread Robert M. Münch via Digitalmars-d-learn
On 2019-10-29 17:43:47 +, H. S. Teoh said: On Tue, Oct 29, 2019 at 04:54:23PM +, ixid via Digitalmars-d-learn wrote: On Tuesday, 29 October 2019 at 16:11:45 UTC, Daniel Kozak wrote: On Tue, Oct 29, 2019 at 5:09 PM Daniel Kozak wrote: AFAIK dmd use real for floating point operations

Re: Accuracy of floating point calculations

2019-10-29 Thread kinke via Digitalmars-d-learn
On Tuesday, 29 October 2019 at 16:20:21 UTC, Daniel Kozak wrote: On Tue, Oct 29, 2019 at 5:09 PM Daniel Kozak wrote: On Tue, Oct 29, 2019 at 4:45 PM Twilight via Digitalmars-d-learn wrote: > > D calculation: >mport std.stdio; import std.math : pow; import core.stdc.math; void main() {

Re: Accuracy of floating point calculations

2019-10-29 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Oct 29, 2019 at 07:10:08PM +, Twilight via Digitalmars-d-learn wrote: > On Tuesday, 29 October 2019 at 16:11:45 UTC, Daniel Kozak wrote: > > On Tue, Oct 29, 2019 at 5:09 PM Daniel Kozak wrote: > > > If you use gdc or ldc you will get same results as c++, or you can > > > use C log

Re: Accuracy of floating point calculations

2019-10-29 Thread Twilight via Digitalmars-d-learn
On Tuesday, 29 October 2019 at 16:11:45 UTC, Daniel Kozak wrote: On Tue, Oct 29, 2019 at 5:09 PM Daniel Kozak wrote: If you use gdc or ldc you will get same results as c++, or you can use C log directly: import std.stdio; import std.math : pow; import core.stdc.math; void main() {

Re: Accuracy of floating point calculations

2019-10-29 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Oct 29, 2019 at 04:54:23PM +, ixid via Digitalmars-d-learn wrote: > On Tuesday, 29 October 2019 at 16:11:45 UTC, Daniel Kozak wrote: > > On Tue, Oct 29, 2019 at 5:09 PM Daniel Kozak wrote: > > > If you use gdc or ldc you will get same results as c++, or you can > > > use C log

Re: Accuracy of floating point calculations

2019-10-29 Thread ixid via Digitalmars-d-learn
On Tuesday, 29 October 2019 at 16:11:45 UTC, Daniel Kozak wrote: On Tue, Oct 29, 2019 at 5:09 PM Daniel Kozak wrote: If you use gdc or ldc you will get same results as c++, or you can use C log directly: import std.stdio; import std.math : pow; import core.stdc.math; void main() {

Re: Accuracy of floating point calculations

2019-10-29 Thread Daniel Kozak via Digitalmars-d-learn
On Tue, Oct 29, 2019 at 5:09 PM Daniel Kozak wrote: > > On Tue, Oct 29, 2019 at 4:45 PM Twilight via Digitalmars-d-learn > wrote: > > > > D calculation: > >mport std.stdio; import std.math : pow; import core.stdc.math; void main() { writefln("%12.3F",log(1-0.)/log(1-(1-0.6)^^20)); } >

Re: Accuracy of floating point calculations

2019-10-29 Thread Daniel Kozak via Digitalmars-d-learn
On Tue, Oct 29, 2019 at 5:09 PM Daniel Kozak wrote: > > > If you use gdc or ldc you will get same results as c++, or you can use > C log directly: > > import std.stdio; > import std.math : pow; > import core.stdc.math; > > void main() > { >

Re: Accuracy of floating point calculations

2019-10-29 Thread Daniel Kozak via Digitalmars-d-learn
On Tue, Oct 29, 2019 at 4:45 PM Twilight via Digitalmars-d-learn wrote: > > D calculation: > >writefln("%12.2F",log(1-0.)/log(1-(1-0.6)^^20)); > > 837675572.38 > > C++ calculation: > >cout< <<'\n'; > > 837675573.587 > > As a second data point, changing 0. to 0.75 yields >

Accuracy of floating point calculations

2019-10-29 Thread Twilight via Digitalmars-d-learn
D calculation: writefln("%12.2F",log(1-0.)/log(1-(1-0.6)^^20)); 837675572.38 C++ calculation: cout<<<'\n'; 837675573.587 As a second data point, changing 0. to 0.75 yields 126082736.96 (Dlang) vs 126082737.142 (C++). The discrepancy stood out as I was ultimately taking the

Re: accuracy of floating point calculations: d vs cpp

2019-07-23 Thread Ali Çehreli via Digitalmars-d-learn
On 07/22/2019 08:48 PM, Timon Gehr wrote: > This is probably not your problem, but it may be good to know anyway: D > allows compilers to perform arbitrary "enhancement" of floating-point > precision for parts of the computation, including those performed at > compile time. I think this is

Re: accuracy of floating point calculations: d vs cpp

2019-07-22 Thread Timon Gehr via Digitalmars-d-learn
On 22.07.19 14:49, drug wrote: I have almost identical (I believe it at least) implementation (D and C++) of the same algorithm that uses Kalman filtering. These implementations though show different results (least significant digits). Before I start investigating I would like to ask if this

Re: accuracy of floating point calculations: d vs cpp

2019-07-22 Thread drug via Digitalmars-d-learn
22.07.2019 17:19, drug пишет: 22.07.2019 16:26, Guillaume Piolat пишет: Typical floating point operations in single-precision like a simple (a * b) + c will provide a -140dB difference if order is changed. It's likely the order of operations is not the same in your program, so the least

Re: accuracy of floating point calculations: d vs cpp

2019-07-22 Thread drug via Digitalmars-d-learn
22.07.2019 16:26, Guillaume Piolat пишет: Typical floating point operations in single-precision like a simple (a * b) + c will provide a -140dB difference if order is changed. It's likely the order of operations is not the same in your program, so the least significant digit should be

Re: accuracy of floating point calculations: d vs cpp

2019-07-22 Thread Dennis via Digitalmars-d-learn
On Monday, 22 July 2019 at 12:49:24 UTC, drug wrote: Before I start investigating I would like to ask if this issue (different results of floating points calculation for D and C++) is well known? This likely has little to do with the language, and more with the implementation. Basic floating

Re: accuracy of floating point calculations: d vs cpp

2019-07-22 Thread Guillaume Piolat via Digitalmars-d-learn
On Monday, 22 July 2019 at 13:23:26 UTC, Guillaume Piolat wrote: On Monday, 22 July 2019 at 12:49:24 UTC, drug wrote: I have almost identical (I believe it at least) implementation (D and C++) of the same algorithm that uses Kalman filtering. These implementations though show different results

Re: accuracy of floating point calculations: d vs cpp

2019-07-22 Thread Guillaume Piolat via Digitalmars-d-learn
On Monday, 22 July 2019 at 12:49:24 UTC, drug wrote: I have almost identical (I believe it at least) implementation (D and C++) of the same algorithm that uses Kalman filtering. These implementations though show different results (least significant digits). Before I start investigating I would

Re: accuracy of floating point calculations: d vs cpp

2019-07-22 Thread rikki cattermole via Digitalmars-d-learn
On 23/07/2019 12:58 AM, drug wrote: 22.07.2019 15:53, rikki cattermole пишет: https://godbolt.org/z/EtZLG0 hmm, in short - this is my local problem? That is not how I would describe it. I would describe it as IEEE-754 doing what IEEE-754 is good at. But my point is, you can get the

Re: accuracy of floating point calculations: d vs cpp

2019-07-22 Thread drug via Digitalmars-d-learn
22.07.2019 15:53, rikki cattermole пишет: https://godbolt.org/z/EtZLG0 hmm, in short - this is my local problem?

Re: accuracy of floating point calculations: d vs cpp

2019-07-22 Thread rikki cattermole via Digitalmars-d-learn
On 23/07/2019 12:49 AM, drug wrote: I have almost identical (I believe it at least) implementation (D and C++) of the same algorithm that uses Kalman filtering. These implementations though show different results (least significant digits). Before I start investigating I would like to ask if

accuracy of floating point calculations: d vs cpp

2019-07-22 Thread drug via Digitalmars-d-learn
I have almost identical (I believe it at least) implementation (D and C++) of the same algorithm that uses Kalman filtering. These implementations though show different results (least significant digits). Before I start investigating I would like to ask if this issue (different results of