Re: Peculiar number formatting?
"Pascal Bourguignon (as informatimago at gmail dot com)" <[email protected]> Wed, 20 May 2026 17:44:40 +0200
| Newsgroups | gmane.lisp.lispworks.general |
|---|---|
| Message-ID | <[email protected]> |
> On 19 May 2026, at 23:29, David McClain <[email protected]> wrote: > > No, in retrospect, I see that my confusion arises entirely from having first been exposed to C printf(). In their format specs, the prefix 0, as in %05x (IIRC) means that you want 5 digits, and if necessary, fill the left with zeros. > > In Lisp, the prefix count specifies a field width, which is entirely different. But it appears to work the same as long as you print positive numbers. So I guess, in all of 30 years of Lisp use, I never tried to print a zero filled negative hex number, until now. > > Lisp is offering the ancient formatting convention of filling a numeric field with some char of your choice, which was often used in printing dollar amounts on checks. It was an ancient security measure to help prevent people from writing their own prefix digits before cashing in. > > It is easy to provide my own formatter which gives N digits, regardless of field width. I just always assumed that Lisp worked the way C printf() does. It does not. But when you must, you can rather easily.  -- __Pascal Bourguignon__ [email protected]