Another take on decimal data types

kdevel kdevel at vogtner.de
Thu Jan 11 20:35:03 UTC 2018


Great project!

On Monday, 8 January 2018 at 22:16:25 UTC, rumbu wrote:
> - all format specifiers implemented (%f, %e, %g, %a);

Really?

[...]

> What's next:
> - more tests;

Here you are:

```
import std.stdio;
import decimal;

void main ()
{
    decimal32 d = "0.7";
    d *= decimal32("1.05");
    d.writeln;
    printf ("%.2f\n", d);

    float f = 0.7f;
    f *= 1.05f;
    f.writeln;
    printf ("%.2f\n", f);

    decimal32 e = 1_000_000_000;
    while (e > 1e-7) {
       e.writeln;
       e /= 10;
    }
}
```

This prints:

    0.735
    0.00      <--- expected: 0.74
    0.735
    0.73
              <--- loop output missing

(DMD64 D Compiler v2.077.1)


More information about the Digitalmars-d-announce mailing list