Another take on decimal data types

kdevel kdevel at vogtner.de
Thu Jan 11 21:24:30 UTC 2018


On Thursday, 11 January 2018 at 20:44:13 UTC, kdevel wrote:
> On Thursday, 11 January 2018 at 20:35:03 UTC, kdevel wrote:
>>              <--- loop output missing

loop.d
```
import std.stdio;
import decimal;

void loopme(T) ()
{
    "---".writeln;
    T e = T(1000);
    while (e > T(1e-6)) {
       e.writeln;
       e /= 10;
    }
}

void main ()
{
    loopme!float;
    loopme!decimal32;
}
```

This prints

    ---
    1000
    100
    10
    1
    0.1
    0.01
    0.001
    0.0001
    1e-05
    ---
    1000
    100
    10
    1
    0.1
    0.0100000    <--
    0.00100000   <--
    0.000100000  <--
    1.00000e-05  <--

Why are there trailing zeroes?


More information about the Digitalmars-d-announce mailing list