[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Floating-point formatting string

From: Juanma Barranquero
Subject: Re: Floating-point formatting string
Date: Wed, 14 Feb 2007 17:35:39 +0100

On 2/14/07, Stuart D. Herring <address@hidden> wrote:

That doesn't quite explain Vinicius' other examples; in particular,

M-: (format "% 3.3f" 1.2)
==> " 1.200"

which has been padded even though it's longer than 3 characters without
the space.

That's not padding. The flag " " does not mean "pad with spaces", but
"inserts a space for positive numbers". That helps with columns, if
the number can also be negative:

ELISP> (format "%3.3f" 1.2)
ELISP> (format "%3.3f" -1.2)
ELISP> (format "% 3.3f" 1.2)
" 1.200"
ELISP> (format "% 3.3f" -1.2)

Space-padding is specified by using no flag:

ELISP> (format "%6.3f" -1.2)
ELISP> (format "%6.3f" 1.2)
" 1.200"


reply via email to

[Prev in Thread] Current Thread [Next in Thread]