diff --git a/src/clojure/contrib/pprint/cl-format.clj b/src/clojure/contrib/pprint/cl-format.clj index 64fc4f30..b0531c14 100644 --- a/src/clojure/contrib/pprint/cl-format.clj +++ b/src/clojure/contrib/pprint/cl-format.clj @@ -759,7 +759,7 @@ Note this should only be used for the last one in the sequence" d (:d params) ; digits after the decimal n (:n params) ; minimum digits before the decimal w (:w params) ; minimum field width - add-sign (and (:at params) (not (neg? arg))) + add-sign (or (:at params) (neg? arg)) [rounded-mantissa scaled-exp _] (round-str mantissa exp d nil) #^String fixed-repr (get-fixed rounded-mantissa scaled-exp d) full-repr (str (apply str (repeat (- n (.indexOf fixed-repr (int \.))) \0)) fixed-repr) diff --git a/src/clojure/contrib/test_contrib/pprint/cl_format.clj b/src/clojure/contrib/test_contrib/pprint/cl_format.clj index 81d64c78..6684bff2 100644 --- a/src/clojure/contrib/test_contrib/pprint/cl_format.clj +++ b/src/clojure/contrib/test_contrib/pprint/cl_format.clj @@ -176,7 +176,22 @@ (cl-format nil "~3,5,14@$" 22.375) " +00022.375" (cl-format nil "~3,5,14@$" 22.375) " +00022.375" (cl-format nil "~3,5,14@:$" 22.375) "+ 00022.375" - (cl-format nil "~3,,14@:$" 0.375) "+ 0.375") + (cl-format nil "~3,,14@:$" 0.375) "+ 0.375" + (cl-format nil "~1,1$" -12.0) "-12.0" + (cl-format nil "~1,1$" 12.0) "12.0" + (cl-format nil "~1,1$" 12.0) "12.0" + (cl-format nil "~1,1@$" 12.0) "+12.0" + (cl-format nil "~1,1,8,' @:$" 12.0) "+ 12.0" + (cl-format nil "~1,1,8,' @$" 12.0) " +12.0" + (cl-format nil "~1,1,8,' :$" 12.0) " 12.0" + (cl-format nil "~1,1,8,' $" 12.0) " 12.0" + (cl-format nil "~1,1,8,' @:$" -12.0) "- 12.0" + (cl-format nil "~1,1,8,' @$" -12.0) " -12.0" + (cl-format nil "~1,1,8,' :$" -12.0) "- 12.0" + (cl-format nil "~1,1,8,' $" -12.0) " -12.0") + +(simple-tests f-tests + (cl-format nil "~,1f" -12.0) "-12.0") (simple-tests ampersand-tests (cl-format nil "The quick brown ~a jumped over ~d lazy dogs" 'elephant 5)