Details
-
Type:
Defect
-
Status:
Closed
-
Resolution: Completed
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
Description
As reported in the google group (http://groups.google.com/group/clojure/browse_thread/thread/ae3e636a44c95686):
Hello,
I've encountered a couple of issues with the cl-format function
included in contrib.pprint
(cl-format nil "~1,1$" -12.0) ;; => "12.0" the sign is lost
I think the problem is the following assignment in the dollar-float
function
add-sign (and (:at params) (not (neg? arg))) ;; wrong
(the sign is only printed when the colon modifier is present and only
for positive numbers)
that should read, if I understand correctly the logic,
add-sign (or (:at params) (neg? arg))
The second issue is not so straightforward to solve:
(cl-format true "1,1$%" 0.001) ;; => String index out of range: -1
I've tracked down the bug into the function round-str (the variable
round-pos will be negative and this case is not handled properly), but
I don't understand the code well enough to propose a fix.
Cheers,
Carlos
Converted from http://www.assembla.com/spaces/clojure/tickets/40