I want to print floats in a good way. In particular, I want to print two numbers after the decimal point, but only if these numbers are not equal to zero.
This works if the number is not an even integer:
(let ((f 1.240)) (format t "~,2F" f)) --> 1.24
But if the number is an integer, I get the following:
(let ((f 1240)) (format t "~,2F" f)) -->1240.00
Is there any elegant way to do this, or do I need to check the number of decimal points manually before printing?
source share