Steel Bank Common Lisp

Fixed-Format Floating-Point with scaling factor broken

Reported by Michael Wells on 2011-07-16
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Undecided
Unassigned

Bug Description

In SBCL 1.0.50,

(format nil "~7,2,-2f" 0) ==> " 0.000"
but it should output " 0.00"

uname -a ==>
Linux XXX.XXX.XXX 2.6.18-194.32.1.el5PAE #1 SMP Wed Jan 5 18:43:13 EST 2011 i686 i686 i386 GNU/Linux

*features*
(:ANSI-CL :COMMON-LISP :SBCL :SB-DOC :SB-TEST :SB-LDB :SB-PACKAGE-LOCKS
 :SB-UNICODE :SB-EVAL :SB-SOURCE-LOCATIONS :IEEE-FLOATING-POINT :X86 :UNIX :ELF
 :LINUX :SB-THREAD :LARGEFILE :GENCGC :STACK-GROWS-DOWNWARD-NOT-UPWARD
 :C-STACK-IS-CONTROL-STACK :COMPARE-AND-SWAP-VOPS :UNWIND-TO-FRAME-AND-CALL-VOP
 :RAW-INSTANCE-INIT-VOPS :STACK-ALLOCATABLE-CLOSURES :STACK-ALLOCATABLE-VECTORS
 :STACK-ALLOCATABLE-LISTS :STACK-ALLOCATABLE-FIXED-OBJECTS :ALIEN-CALLBACKS
 :CYCLE-COUNTER :INLINE-CONSTANTS :MEMORY-BARRIER-VOPS :LINKAGE-TABLE
 :OS-PROVIDES-DLOPEN :OS-PROVIDES-DLADDR :OS-PROVIDES-PUTWC
 :OS-PROVIDES-SUSECONDS-T :OS-PROVIDES-GETPROTOBY-R :OS-PROVIDES-POLL)

Lutz Euler (lutz-euler) wrote :

To advance this case a little bit:

This has been working correctly for ages and only been broken very recently.
git bisect points to:

  58187b3f2ab87bce54657c9c94ac2b3090103ba1 is the first bad commit
  commit 58187b3f2ab87bce54657c9c94ac2b3090103ba1
  Author: David Vázquez <email address hidden>
  Date: Mon Jun 28 17:28:08 2010 +0200

  FLONUM-TO-DIGITS handles non-negative input properly

  lp#308961, part 1.

This corresponds to version 1.0.49.44.

HTH,

Lutz

Lutz Euler (lutz-euler) wrote :

There is a related bug:

(format nil "~7,2,-2f" 0.1) ==> " 0.001"
Expected output is " 0.00".

This too has been working correctly at some time in the past,
but in this case a very distant past.
I can't build very old SBCL versions any more, so I can only say:
The newest version that I could test where this works as
expected is 0.8.16.
The oldest version that I could test where it is broken
is 0.9.5.73.

Kind regards

Lutz

Changed in sbcl:
status: New → In Progress
Nikodemus Siivola (nikodemus) wrote :

This should fix both issues mentioned above.

commit 8f1d4a2508e8d81564822a1668fe30a490b9c3f6
Author: Nikodemus Siivola <email address hidden>
Date: Fri Jul 29 14:41:00 2011 +0300

    fixed-format floating point printing: zero and scaling factors

      Now that FLONUM-TO-DIGITS handles zero, we need to check against
      zero before adding in the scaling factor.

      Also make sure not to print extra digits when E is negative.

      Adjust FORMAT-AUX-EXP to not print the extra-zero: FLONUM-TO-STRING
      provides it now.

      Fixes lp#811386.

Changed in sbcl:
status: In Progress → Fix Committed
Changed in sbcl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers