The floating point formatting by sprintf has always -- going way back to the earliest of C compilers -- left a lot to be desired.
Indeed. I don't use printf that often, so I tend to forget that the number preceding the decimal point specifies how many total characters there are, instead of how many digits before the decimal point, which seems more intuitive to me. So I too often try something like %3.2f, expecting that to handle numbers like 123.45, before remembering that the first digit has to include the length of the second (and the decimal point).
Aaron B.
My Woefully Neglected Blog, where I occasionally mention Perl.
In reply to Re^2: printf exact field width of floating point number
by aaron_baugher
in thread printf exact field width of floating point number
by flipper
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |