Fixed-Format Floating-Point with scaling factor broken

Bug #811386 reported by Michael Wells on 2011-07-16
This bug affects 1 person
Affects Status Importance Assigned to Milestone

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


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



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

Kind regards


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