Re: writeln double precision

2017-10-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, October 24, 2017 16:59:31 Arun Chandrasekaran via Digitalmars-d- learn wrote: > On Tuesday, 24 October 2017 at 16:18:03 UTC, H. S. Teoh wrote: > > On Tue, Oct 24, 2017 at 10:02:11AM +, Arun Chandrasekaran > > > > via Digitalmars-d-learn wrote: > >> On Monday, 23 October 2017 at 18:0

Re: writeln double precision

2017-10-24 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Oct 24, 2017 at 04:59:04PM +, jmh530 via Digitalmars-d-learn wrote: > On Tuesday, 24 October 2017 at 16:18:03 UTC, H. S. Teoh wrote: > > > > I have never seen a programming language in which dividing two > > integers yields a float or double. Either numbers default to a > > floating p

Re: writeln double precision

2017-10-24 Thread Ali Çehreli via Digitalmars-d-learn
On 10/24/2017 09:59 AM, Arun Chandrasekaran wrote: >>> On Monday, 23 October 2017 at 18:08:43 UTC, Ali Çehreli wrote: >>> > The rule is that every expression has a type and 22/7 is int. > I'm just questioning the reasoning behind why D does it this way and if > it is for compatibility or if the

Re: writeln double precision

2017-10-24 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 24 October 2017 at 16:18:03 UTC, H. S. Teoh wrote: I have never seen a programming language in which dividing two integers yields a float or double. Either numbers default to a floating point type, in which case you begin with floats in the first place, or division is integer div

Re: writeln double precision

2017-10-24 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Tuesday, 24 October 2017 at 16:18:03 UTC, H. S. Teoh wrote: On Tue, Oct 24, 2017 at 10:02:11AM +, Arun Chandrasekaran via Digitalmars-d-learn wrote: On Monday, 23 October 2017 at 18:08:43 UTC, Ali Çehreli wrote: > On 10/23/2017 07:22 AM, Arun Chandrasekaran wrote: > > [...] > The rule is

Re: writeln double precision

2017-10-24 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Oct 24, 2017 at 10:02:11AM +, Arun Chandrasekaran via Digitalmars-d-learn wrote: > On Monday, 23 October 2017 at 18:08:43 UTC, Ali Çehreli wrote: > > On 10/23/2017 07:22 AM, Arun Chandrasekaran wrote: > > > [...] > > The rule is that every expression has a type and 22/7 is int. > > Th

Re: writeln double precision

2017-10-24 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Monday, 23 October 2017 at 18:08:43 UTC, Ali Çehreli wrote: On 10/23/2017 07:22 AM, Arun Chandrasekaran wrote: > [...] The rule is that every expression has a type and 22/7 is int. Thanks Ali. Is this for backward compatibility with C? Because, if there is a division, a natural/mathematical

Re: writeln double precision

2017-10-23 Thread Ali Çehreli via Digitalmars-d-learn
On 10/23/2017 07:22 AM, Arun Chandrasekaran wrote: > void main() { > double a = 22/7.0; > import std.stdio: writeln, writefln; > writefln("%.51f", a); > } > But why does the compiler bring the C baggage for the integer > division? Why do I need to `cast (double)` ? I think you mea

Re: writeln double precision

2017-10-23 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Monday, 23 October 2017 at 14:07:06 UTC, Arun Chandrasekaran wrote: I've written a simple tool [1] to find the DET and CMC specifically for biometrics performance measurement. When I generate the report, I expected to see high precision floating point numbers, but I see that writefln trims

writeln double precision

2017-10-23 Thread Arun Chandrasekaran via Digitalmars-d-learn
I've written a simple tool [1] to find the DET and CMC specifically for biometrics performance measurement. When I generate the report, I expected to see high precision floating point numbers, but I see that writefln trims the precision to the last 6 digits after decimal point. Am I doing th