a26bbbf15587 default tip
Fix negative pf
author | Steve Losh <steve@stevelosh.com> |
---|---|
date | Wed, 05 Mar 2025 15:14:45 -0500 |
parents | dee136fa9a81 |
children | (none) |
branches/tags | default tip |
files | src/math.lisp |
Changes
--- a/src/math.lisp Wed Mar 05 15:09:34 2025 -0500 +++ b/src/math.lisp Wed Mar 05 15:14:45 2025 -0500 @@ -426,10 +426,12 @@ (define-command pf (x) "Print x as a nicely-formatted number." - (multiple-value-bind (ipart fpart) (ftruncate x) - (let ((ipart (round ipart)) - (fpart (if (zerop fpart) - "" - (subseq (format nil "~F" (abs fpart)) 1)))) - (format t "~:D~A" ipart fpart))) + (let ((sign (if (minusp x) "-" "")) + (x (abs x))) + (multiple-value-bind (ipart fpart) (ftruncate x) + (let ((ipart (round ipart)) + (fpart (if (zerop fpart) + "" + (subseq (format nil "~F" fpart) 1)))) + (format t "~A~:D~A" sign ipart fpart)))) (values))