[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Proposed new FORMAT operator: ~U("units")
- To: bug-lisp at MIT-AI, bug-lispm at MIT-AI, common-lisp at SU-AI
- Subject: Proposed new FORMAT operator: ~U("units")
- From: Quux
- Date: Sat, 12 Jun 1982 02:33:00 -0000
- Reply-to: Guy.Steele at CMU-10A
- Sender: Guy.Steele at CMU-10A
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!