Skip navigation.
 
mlRe: decimal floating formatting question
FROM : Jonathan Jackel
DATE : Fri Dec 24 17:51:07 2004

Try %g.  According to man printf, "The argument is printed in style f
or in style e (E) whichever gives full precision in minimum space." 
It's not exactly what you want, but close.  JJ.

On Dec 22, 2004, at 6:59 PM, Mark Dawson wrote:

> Is there a way to format a decimal number with no trailing zeros and
> show only "X" number of digits?  I would like 1.0 to show up as "1",
> 1.2 as '1.2";, 1.31457 as "1.3146".
>
> I'm familiar with the "%.4f" type format, but while this limits the
> output to 4 decimal points, it adds trailing zeros (i.e., "1.2000"). 
> Is there a way to the best of both worlds via a formatting option?
>
> Thanks!
>
> mark

Related mailsAuthorDate
mldecimal floating formatting question Mark Dawson Dec 23, 00:59
mlRe: decimal floating formatting question Ricky Sharp Dec 23, 01:34
mlRe: decimal floating formatting question Jonathan Jackel Dec 23, 04:02
mlRe: decimal floating formatting question Jonathan Jackel Dec 24, 17:51