Opened 13 years ago

Last modified 17 months ago

#190 new defect

FORMAT DOLLARSIGN fails to handle rounding negative arguments

Reported by: Mark Evenson Owned by: ehuelsmann
Priority: critical Milestone: 1.9.3
Component: interpreter Version: 1.0
Keywords: ansi-conformance Cc:
Parent Tickets:

Description (last modified by Mark Evenson)

In <http://article.gmane.org/gmane.lisp.armedbear.devel/2138> Marshall Abrams reports:

It looks as if there's a bug in 1.0.0 with FORMAT's dollarsign directive's handling of negative numbers when it has to round up. (Forgive me if this is a known issue--I didn't find it when I searched the bug list and mailing list archives--or if there's something I'm misunderstanding.)

The first group of examples use the F directive for comparison to show that the problem seems to be specific to dollarsign. (I added blank lines between example groups for easy reading.)

The second group of examples illustrates a problem using dollarsign with negative numbers. The output is about 10x too large, and doesn't seem to be getting rounded properly. I'm guessing that the out of bounds error is the result of the same issue.

The third group of examples shows that the problem doesn't seem to occur with positive numbers, although there's still an extra negative sign prepended.

Thank you-

Marshall Abrams

Armed Bear Common Lisp 1.0.0-svn-13663
Java 1.6.0_29 Apple Inc.
Java HotSpot(TM) 64-Bit Server VM
Low-level initialization completed in 0.7 seconds.
Startup completed in 2.211 seconds.
Type ":help" for a list of available commands.

CL-USER(1): (format t "~,vf" 3 -0.1768522)
-0.177
NIL
CL-USER(2): (format t "~,vf" 2 -0.1768522)
-0.18
NIL
CL-USER(3): (format t "~,vf" 1 -0.1768522)
-0.2
NIL
CL-USER(4): (format t "~,vf" 0 -0.1768522)
-0.
NIL

CL-USER(5): (format t "~$" -0.1768522)
--1.6
NIL
CL-USER(6): (format t "~v$" 3 -0.1768522)
--1.75
NIL
CL-USER(7): (format t "~v$" 2 -0.1768522)
--1.6
NIL
CL-USER(8): (format t "~v$" 1 -0.1768522)
#<THREAD "interpreter" {10FA1B2D}>: Debugger invoked on condition of type TYPE-ERROR
 Array index out of bounds: 2
Restarts:
 0: TOP-LEVEL Return to top level.
[1] CL-USER(9): 0
CL-USER(10): (format t "~v$" 0 -0.1768522)
--0.
NIL

CL-USER(11): (format t "~$" 0.1768522)
0.18
NIL
CL-USER(12): (format t "~v$" 3 0.1768522)
0.177
NIL
CL-USER(13): (format t "~v$" 2 0.1768522)
0.18
NIL
CL-USER(14): (format t "~v$" 1 0.1768522)
0.2
NIL
CL-USER(15): (format t "~v$" 0 0.1768522)
0.
NIL

Change History (28)

comment:1 Changed 13 years ago by Mark Evenson

Milestone: 1.0.11.1.0

comment:2 Changed 12 years ago by Mark Evenson

Keywords: ansi-conformance added
Priority: minormajor

comment:3 Changed 12 years ago by Mark Evenson

Milestone: 1.1.01.1.1

comment:4 Changed 12 years ago by Mark Evenson

Milestone: 1.1.11.2.0

comment:5 Changed 12 years ago by Evenson Not Org

Priority: majorcritical

comment:6 Changed 11 years ago by Evenson Not Org

Milestone: 1.2.01.3.0

comment:7 Changed 11 years ago by Mark Evenson

Milestone: 1.3.02.0

Ticket retargeted after milestone closed

comment:8 Changed 11 years ago by Mark Evenson

Milestone: 2.02.0.0

Milestone renamed

comment:9 Changed 11 years ago by Mark Evenson

Milestone: 2.0.01.4.0

comment:10 Changed 8 years ago by Mark Evenson

Milestone: 1.4.01.5.0

Ticket retargeted after milestone closed

comment:11 Changed 7 years ago by Mark Evenson

Milestone: 1.5.01.6.0

Ticket retargeted after milestone closed

comment:12 Changed 5 years ago by Mark Evenson

Description: modified (diff)

comment:13 Changed 5 years ago by Mark Evenson

Description: modified (diff)

comment:14 Changed 5 years ago by Mark Evenson

Description: modified (diff)

comment:15 Changed 5 years ago by Mark Evenson

In <https://mailman.common-lisp.net/pipermail/armedbear-devel/2019-March/003956.html> dingd noted

this is what sbcl does

* (format nil "~$" -0.0)
"-0.00"

comment:16 Changed 5 years ago by Mark Evenson

See also #314

comment:17 Changed 5 years ago by Mark Evenson

Milestone: 1.6.01.6.1

Ticket retargeted after milestone closed

comment:18 Changed 5 years ago by Mark Evenson

Milestone: 1.6.11.6.2

Ticket retargeted after milestone closed

comment:19 Changed 4 years ago by Mark Evenson

Milestone: 1.6.21.7.0

comment:20 Changed 4 years ago by Mark Evenson

Milestone: 1.7.01.7.1

Ticket retargeted after milestone closed

comment:21 Changed 4 years ago by Mark Evenson

Milestone: 1.7.11.7.2

Ticket retargeted after milestone closed

comment:22 Changed 4 years ago by Mark Evenson

Milestone: 1.7.21.8.0

Milestone renamed

comment:23 Changed 4 years ago by Mark Evenson

I think this is fixed, but we should extract an executable test to "prove" it.

comment:24 Changed 4 years ago by Mark Evenson

Milestone: 1.8.01.8.1

Ticket retargeted after milestone closed

comment:25 Changed 3 years ago by Mark Evenson

Milestone: 1.8.11.9.0

comment:26 Changed 22 months ago by Mark Evenson

Milestone: 1.9.01.9.1

comment:27 Changed 21 months ago by Mark Evenson

Milestone: 1.9.11.9.2

comment:28 Changed 17 months ago by Mark Evenson

Milestone: 1.9.21.9.3
Note: See TracTickets for help on using tickets.