Ticket #992 (closed defect: fixed)

Opened 22 months ago

Last modified 22 months ago

format ~9,2$ gives inconsistent results.

Reported by: pjb@… Owned by:
Priority: normal Milestone:
Component: ANSI CL Compliance Version: trunk
Keywords: format ~$ Cc:

Description

A funny bug with ~$ formating:

(defparameter *inflation*      1.06)
(defparameter *duration*      15          "Year")
(defparameter *yearly-amount* (* 12 1200) "Euro")
(defparameter *now-a-year*    (nth-value 5 (decode-universal-time (get-universal-time))))

(defun plus-interest (amount year rate)
  (* amount (expt year rate)))

(with-standard-io-syntax
 (loop
   :for i :from 15 :downto 0
   :for that-year-amount = (plus-interest *yearly-amount* i *inflation*)
   :sum that-year-amount :into total
   :do (format t "~4D:   ~2,9$   ~2,9$~%" (+ *now-a-year* i) that-year-amount total)))
2027:   000254108.47   000254108.47
2026:   000236188.17   000490296.62
2025:   000218344.56   000708641.20
2024:   000200583.20   000909224.40
2023:   000182910.52   001092134.90
2022:   000165334.11   1257469.00
2021:   147863.00   1405332.00
2020:   000130508.21   001535840.20
2019:   000113283.42   001649123.60
2018:   000096206.13   001745329.70
2017:   000079299.54   001824629.20
2016:   000062595.92   001887225.10
2015:   000046143.55   001933368.60
2014:   000030023.01   001963391.60
2013:   14400.00   001977791.60
2012:   000000000.00   001977791.60
nil

Change History

comment:1 Changed 22 months ago by gb

  • Status changed from new to closed
  • Resolution set to fixed

(In [15421]) format-dollars ($ directive): print leading zeroes even if trailing zeroes.

Fixes ticket:992 in the trunk.

Note: See TracTickets for help on using tickets.