Re: Since we're talking about number formatting

"David McClain (as dbm at refined-audiometrics dot com)" <[email protected]> Wed, 29 Apr 2026 05:38:09 -0700
Newsgroups gmane.lisp.lispworks.general
Message-ID <[email protected]>
I have wrestled with this one myself. 

It appears that Lisp was designed back in the day of RPG and field widths, rather than the scientific approach with significant figures. Even the Fortran IV of the time dealt with field widths, rather than significant figures. 

At least the default for Lisp is to overfill and print the actual number, rather than filling the width with “*” chars.

Even the input spec is a bit off. The decimal point ending of a number serves to indicate base-#10r10, rather than unit significance and zero decimal places.


> On Apr 29, 2026, at 03:41, Tim Bradshaw (as tfb at tfeb dot org) <[email protected]> wrote:
> 
> I want to print a bunch of stuff to 2 significant figures (more generally to any fixed number of them).
> 
> So I want
> 
> 0 -> 0.00  and not 0 or 0.0
> 1.1 -> 1.10 and not 1.1
> 9 -> 9.00 same rules
> 10 -> 10.0
> 100 -> 100 (no point)
> 999 -> 999
> 1000 -> 1.00e3
> 
> Is there any standard format incantation which does this?
> 
> In fact I already have to deal with the large-magnitude case as what I actually want is 1.00\times 10^{3} for instance so it's only the small-magnitude case I need to deal with.
> 
> --tim
> 
> _______________________________________________
> Lisp Hug - the mailing list for LispWorks users
> [email protected]
> http://www.lispworks.com/support/lisp-hug.html


_______________________________________________
Lisp Hug - the mailing list for LispWorks users
[email protected]
http://www.lispworks.com/support/lisp-hug.html