[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
- To: firstname.lastname@example.org
- Subject: formatting numbers
- From: email@example.com
- Date: Thu, 23 Feb 1995 14:36:14 -0400
- Sender: firstname.lastname@example.org
I was hacking through a fast way to accomplish printing of atomic
weights to a periodic table depending upon screen size. In the
example below a maximum of 5 significant figures should print if
& only if 5 figures are significant, otherwise 4 or less figures
should print, depending upon whether or not 4 figures are significant.
(dolist (element/aw '((thallium 204.383)
(let ((element (first element/aw))
(aw (second element/aw)))
(format t "~%~A: " element)
(format t (cond ((integerp aw) "~A")
((/= aw (read-from-string (format nil "~5,1F" aw)))
This is the desired behavior, but it seems a bit contrived.
Is there not a more simple & more efficient way to do this?
Sheldon S. Ball