On 8/9/17 4:10 PM, Temtaime wrote:
Sorry, messed up numbers

Expected:

3.11
3.11
3.1
3.1

Seems g outputs one digit less

I was bugged by this too.

It's not a bug. For the %f specifier, the number represents the number of digits *after* the decimal.

For the %g specifier, the number represents the number of digits *before and after* the decimal.

So:

writefln(`%.1g`, 31.11) -> 31

The most annoying thing is that %g is the default specifier for floating point.

-Steve
  • Format g bug ? Temtaime via Digitalmars-d-learn
    • Re: Format g bug ? Temtaime via Digitalmars-d-learn
      • Re: Format g bug ? Steven Schveighoffer via Digitalmars-d-learn

Reply via email to