It appears that the precision parameter in std.format differs from its meaning in printf. Is that expected behavior?

Example:

import std.stdio;
import core.stdc.stdio;

void main()
{
    auto f = 20.66666;
    writeln(f);
    writefln("%0.3s", f);
    printf("%0.3f\n", f);
}

prints:
20.6667
20.7
20.667

It appears that the precision specifier is dictating the total number of digits on *both sides* of the decimal place. Whereas, in C, it's only the number of digits *after* the decimal place.

I'm trying to specify 3 places of precision after the decimal. How do I do this easily?

I'm having a hard time believing this behavior has never been reported, but I can't find anything about it in bugzilla. Tested all the way back to 2.040.

-Steve

Reply via email to