On Sunday, 10 February 2019 at 20:25:02 UTC, Murilo wrote:
It seems this is a feature of D I will have to get used to and
accept the fact I can't always get the same number as in C
What compilers and settings do you use? What you're actually
comparing here are different implementations of the C runtime
library.
```
#include<stdio.h>
int main() {
double a = 99999912343000007654329925.7865;
printf("%f\n", a);
return 0;
}
```
I compiled this with different C compilers on Windows 10 and
found:
DMC: 99999912342999999472000000.000000
GCC: 99999912342999999000000000.000000
CLANG: 99999912342999999470108672.000000
As for D:
```
import core.stdc.stdio: printf;
int main() {
double a = 99999912343000007654329925.7865;
printf("%f\n", a);
return 0;
}
```
DMD: 99999912342999999472000000.000000
LDC: 99999912342999999470108672.000000
DMC and DMD both use the Digital Mars runtime by default. I think
CLANG and LDC use the static libcmt by default while GCC uses the
dynamic msvcrt.dll (not sure about the exact one, but evidently
it's different). So it really hasn't anything to do with D vs. C
but rather what C runtime you use.