[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bug in printf
From: |
Aharon Robbins |
Subject: |
Re: bug in printf |
Date: |
Wed, 1 Aug 2001 15:08:17 +0300 |
Greetings. Re this:
> Date: Wed, 25 Jul 2001 17:10:34 +0200
> Subject: bug in printf
> From: Frank Gunsing <address@hidden>
> To: <address@hidden>
> CC: <address@hidden>
>
> In printf using %wf the number of digits goes beyond the width even
> if not necessary.
>
> The following
>
> printf "|%8f|\n", 1.0
> printf "|%8f|\n", 12.0
> printf "|%8f|\n", 123.0
> printf "|%8f|\n", 1234.0
> printf "|%8f|\n", 12345.0
> printf "|%8f|\n", 123456.0
> printf "|%8f|\n", 1234567.0
> printf "|%8f|\n", 12345678.0
>
> gives as output
>
> |1.000000|
> |12.000000|
> |123.000000|
> |1234.000000|
> |12345.000000|
> |123456.000000|
> |1234567.000000|
> |12345678.000000|
This is exactly what an equivalent C program produces.
> To: address@hidden (Frank Gunsing)
> Cc: address@hidden
> Subject: Re: bug in printf
> From: Andreas Schwab <address@hidden>
>
> address@hidden (Frank Gunsing) writes:
>
> |> In printf using %wf the number of digits goes beyond the width even
> |> if not necessary.
>
> That's correct. The default precision is 6, so the field will be expanded
> as necessary to fit the six decimal digits. This is how the C standard
> specifies it.
>
> Andreas.
Thanks for the clarification, Andreas.
Arnold
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: bug in printf,
Aharon Robbins <=