Preparing for my upcoming ILC talk led me to some old Common
Lisp email archives where I came across this proposal from Guy
Steele:
Date: 11 June 1982 2233-EDT (Friday) From: Quux To: bug-lisp at MIT-AI, bug-lispm at MIT-AI, common-lisp at SU-AI Subject: Proposed new FORMAT operator: ~U("units") Here's a krevitch that will really snork your flads. ~U swallows an argument, which should be a floating-point number (an integer or ratio may be floated first). The argument is then scaled by 10^(3*K) for some integer K, so that it lies in [1.0,1000.0). If this K is suitably small, then the scaled number is printed, then a space, then a metric-system prefix. If not, then the number is printed in exponential notation, then a space. With a :, prints the short prefix. Examples: (FORMAT () "~Umeters, ~Uliters, ~:Um, ~:UHz" 50300.0 6.0 .013 1.0e7) => "50.5 kilometers, 6.0 liters, 13.0 mm, 10.0 MHz" And you thought ~R was bad!
Later he made this small addition:
Date: 12 June 1982 1119-EDT (Saturday) From: Quux To: bug-lisp at MIT-AI, bug-lispm at MIT-AI, common-lisp at SU-AI Subject: More on ~U (short) I forgot to mention that the @ flag should cause scaling by powers of 2^10 instead of 10^3: (format () "~Ubits, ~:Ub, ~@Ubits, ~:@Ub" 65536 65536 65536 65536) => "65.536 kilobits, 65.536 Kb, 64.0 kilobits, 64.0 Kb" --Q