From: ······@rbv.gov.vu
Subject: help format float with comma
Date: 
Message-ID: <1165455663.780359.136380@j44g2000cwa.googlegroups.com>
hi,
i would like to know how to format a float with comma.

e.g

1000.2 - > 1,000.2 

any glue 

many thanks
From: Pascal Bourguignon
Subject: Re: help format float with comma
Date: 
Message-ID: <87veko5tzy.fsf@thalassa.informatimago.com>
······@rbv.gov.vu writes:

> hi,
> i would like to know how to format a float with comma.
>
> e.g
>
> 1000.2 - > 1,000.2 
>
> any glue 

CLHS is the glue: 
http://www.lispworks.com/documentation/HyperSpec/Front/Contents.htm


In particular, see the section 22.3 Formated Output:
http://www.lispworks.com/documentation/HyperSpec/Body/22_c.htm

As you can see, there's no floating point format specifier that can do
it, but the decimal format specifier can do it.  So a partial solution
may be:

(let ((x 45678.02) (w 12) (d 2))
               (let* ((int (round x))
                      (frac (round (* (expt 10 d) (- x int) ))))
                 (format t "~V,' ,',,3:D.~V,'0D" w int d frac)))
      45,678.02


Of course, it won't work for numbers such as 1.2345678
where you'd want them formated as:  1.234,567,8
(exercise left to the reader).

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
        Un chat errant
se soulage
        dans le jardin d'hiver
                                        Shiki