writeln double precision
Arun Chandrasekaran
aruncxy at gmail.com
Mon Oct 23 14:22:40 UTC 2017
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 the
> precision to the last 6 digits after decimal point.
>
> Am I doing the right thing here? Should I use a different
> format specifier?
>
> [1] https://bitbucket.org/carun/biometrics-reports/src
>
> Cheers,
> Arun
```
void main() {
double a = 22/7.0;
import std.stdio: writeln, writefln;
writefln("%.51f", a);
}
```
and it prints all the decimals. So I'm happy that I have not lost
the precision. But why does the compiler bring the C baggage for
the integer division? Why do I need to `cast (double)` ? Can't
the compiler figure it out?
More information about the Digitalmars-d-learn
mailing list