Skip to content
Snippets Groups Projects
  1. Aug 10, 2014
    • Raymond Toy's avatar
      Fix ticket:101, implementing STREAM-ADVANCE-TO-COLUMN for FORMAT ~T. · e585e8d6
      Raymond Toy authored
       * code/format.lisp:
         * Add support for Gray streams for tabulation, calling
           STREAM-ADVANCE-TO-COLUMN as needed.
       * tests/gray-stream.lisp:
         * Add tests for absolute and relative tabulation. These are simple
           and just compare that lisp streams and Gray streams produce the
           same output.
       * general-info/release-20f.txt:
         * Update.
      e585e8d6
  2. Nov 04, 2011
  3. Oct 22, 2011
  4. Oct 21, 2011
  5. Sep 25, 2011
  6. Nov 16, 2010
  7. Apr 20, 2010
  8. Apr 19, 2010
  9. Mar 19, 2010
  10. Aug 09, 2009
  11. Jun 11, 2009
  12. Dec 21, 2008
  13. Jul 14, 2008
  14. Jun 27, 2008
  15. Jun 25, 2008
  16. Jun 23, 2008
  17. Mar 26, 2008
  18. Mar 13, 2008
    • rtoy's avatar
      Fix off-by-one bug in ~R which prevents printing numbers from 10^63 to · 971d3122
      rtoy authored
      10^66-1.  10^63 is a vigintillion.  (From SBCL).
      971d3122
    • rtoy's avatar
      (format nil "~5f" 1d-10) was printing out way too many zeroes, · a660c8de
      rtoy authored
      exceeding the specified width.  I think the correct answer is
      ".0000".
      
      So, add a parameter, allow-overflow-p, to FLONUM-TO-STRING to allow
      the width constraint to be exceeded.  This defaults to T.
      FLONUM-TO-STRING looks at this and decides whether or not to print out
      all the leading zeroes or not.  In FIXED-FORMAT-AUX, set
      allow-overflow-p to NIL so we don't exceed the width.
      
      I wish there were another way to do this, but I can't think of one
      right now.
      
      All print tests pass, and add the following test:
      
      (format nil "~5F" 1d-10) -> ".0000"
      
      print.lisp:
      o Change FLONUM-TO-STRING to use keyword parameters instead of
        optional parameters.
      o Add :ALLOW-OVERFLOW-P, defaulting to T.
      o Use :ALLOW-OVERFLOW-P to determine if all the leading zeroes should
        be printed or not.
      
      format.lisp:
      o Update calls to FLONUM-TO-STRING to use keywords parameters.
      o In FIXED-FORMAT-AUX, set :ALLOW-OVERFLOW-P to NIL
      a660c8de
  19. Feb 29, 2008
  20. Feb 27, 2008
    • rtoy's avatar
      Trac ticket #13. · 74f5a075
      rtoy authored
      Basically caused by a change of exponent due rounding of the number
      for printing.  0.999999 might get printed as 1.000.  The original
      number had an exponent of -1, but the printed number has an exponent
      of 0, and we need to account for this.
      
      code/print.lisp:
      o Modify FLONUM-TO-STRING to take into account of the actual and
        printed exponent of the number.  Return an extra value to indicate
        if rounding has the exponent to change.
      
      code/format.lisp:
      o Use the new return value from FLONUM-TO-STRING to tell us if we need
        to adjust the printed exponent to account for the rounding change.
      
      All print tests still pass, and we add the following tests:
      
      (assert (string= (format nil "~11,3,2,0,'*,,'EE" .99) "  0.990E+00"))
      (assert (string= (format nil "~11,3,2,0,'*,,'EE" .999) "  0.999E+00"))
      (assert (string= (format nil "~11,3,2,0,'*,,'EE" .9999) "  0.100E+01"))
      (assert (string= (format nil "~11,3,2,0,'*,,'EE" .0000999) "  0.999E-04"))
      (assert (string= (format nil "~11,3,2,0,'*,,'EE" .00009999) "  0.100E-03"))
      (assert (string= (format nil "~11,3,2,,'*,,'EE" .00009999) "  9.999E-05"))
      (assert (string= (format nil "~11,3,2,,'*,,'EE" .000099999) "  1.000E-04"))
      74f5a075
  21. Jan 31, 2008
    • rtoy's avatar
      Revise again. Don't limit the fraction digits. Just print out · 3c160594
      rtoy authored
      whatever dd says.  This allows ~G to match what Fortran does, and also
      defers to ~F to let it decide what to do.
      
      The following tests now fail:
      
      (assert (string= (format nil "~9,5G" pi) "3.142    "))
      (assert (string= (format nil "~12,,,,'%g" 1.2345678d1) "12.34568 "))
      
      The former should be
      (assert (string= (format nil "~9,5G" pi) "3.1416    "))
      
      and the latter should be removed or changed to
      
      (assert (string= (format nil "~12,,,,'%g" 1.2345678d1) "%%%%%%%%%%%%"))
      3c160594
  22. Jan 30, 2008
  23. Jan 29, 2008
    • rtoy's avatar
      Minor tweak. dd is always positive in the fixed format case for · 92c0d760
      rtoy authored
      format-general-aux.
      92c0d760
    • rtoy's avatar
      o (format nil "~9,3,2,-2,'%@E" 1100.0) was printing %%%%%%. It should · c7a4509f
      rtoy authored
        print "+.001e+06"
      o Major changes for ~g.  See the comments in format-general-aux for
        more details.
        - ~g will choose ~e more often now, especially for large numbers.
        - ~g when using ~F as the output format won't overflow if the number
          has lots of significant digits.
        - Excessive number of digits has been suppressed.
        - The original d value is used for ~g, instead of the computed
          value.
      
      
      Here is the test suite used.  All tests passed.
      
      (assert (string= (format nil "~9,3,2,0,'%G" 0.0314159) "0.314e-01"))
      (assert (string= (format nil "~9,3,2,-2,'%@e" 3.14159) "+.003e+03"))
      (assert (string= (format nil "~6,2,1,'*F" 3.14159) " 31.42"))
      (assert (string= (format nil "~9,0,6f" 3.14159) " 3141590."))
      
      ;; Make sure a significant digit is printed with the bad choice of
      ;; scale factor.  Width is exceeded.
      (assert (string= (format nil "~9,4,,-7E" pi) ".00000003d+8"))
      (assert (string= (format nil "~9,4,,-5E" pi) ".000003d+6"))
      (assert (string= (format nil "~5,4,,7E" pi) "3141600.d-6"))
      (assert (string= (format nil "~11,4,,3E" pi) "  314.16d-2"))
      (assert (string= (format nil "~11,4,,5E" pi) "  31416.d-4"))
      (assert (string= (format nil "~11,4,,0E" pi) "  0.3142d+1"))
      (assert (string= (format nil "~9,,,-1E" pi) ".03142d+2"))
      (assert (string= (format nil "~,,,-2E" pi) "0.003141592653589793d+3"))
      (assert (string= (format nil "~,,,2E" pi) "31.41592653589793d-1"))
      (assert (string= (format nil "~E" pi) "3.141592653589793d+0"))
      (assert (string= (format nil "~9,5,,-1E" pi) ".03142d+2"))
      (assert (string= (format nil "~11,5,,-1E" pi) " 0.03142d+2"))
      (assert (string= (format nil "~G" pi) "3.141592653589793    "))
      ;; This test exceeds the specified width, unnecessarily.
      ;;(assert (string= (format nil "~9,5G" pi) "3.1416    "))
      (assert (string= (format nil "~9,5G" pi) "3.142    "))
      (assert (string= (format nil "|~13,6,2,7E|" pi) "| 3141593.d-06|"))
      (assert (string= (format nil "~9,3,2,0,'%E" pi) "0.314d+01"))
      (assert (string= (format nil "~9,0,6f" pi) " 3141593."))
      (assert (string= (format nil "~6,2,1,'*F" pi) " 31.42"))
      (assert (string= (format nil "~6,2,1,'*F" (* 100 pi)) "******"))
      (assert (string= (format nil "~9,3,2,-2,'%@E" pi) "+.003d+03"))
      (assert (string= (format nil "~10,3,2,-2,'%@E" pi) "+0.003d+03"))
      (assert (string= (format nil "~15,3,2,-2,'%,'=@E" pi) "=====+0.003d+03"))
      (assert (string= (format nil "~9,3,2,-2,'%E" pi) "0.003d+03"))
      (assert (string= (format nil "~8,3,2,-2,'%@E" pi) "%%%%%%%%"))
      
      (assert (string= (format nil "~g" 1e0) "1.    "))
      ;; This test is one interpration of the spec.  We don't use this.
      ;;(assert (string= (format nil "~g" 1.2d40) "12000000000000000000000000000000000000000.    "))
      (assert (string= (format nil "~g" 1.2d40) "1.2d+40"))
      
      (assert (string= (format nil "~e" 0) "0.0e+0"))
      (assert (string= (format nil "~e" 0d0) "0.0d+0"))
      (assert (string= (format nil "~9,,4e" 0d0) "0.0d+0000"))
      (assert (string= (format nil "~E" 1.234567890123456789d4) "1.2345678901234567d+4"))
      
      (assert (string= (format nil "~20E" (expt 2d0 120)) "1.32922799578492d+36"))
      (assert (string= (format nil "~21,8E" (expt 2d0 120)) "       1.32922800d+36"))
      (assert (string= (format nil "~9,,,-2E" 1.2345689d3) ".00123d+6"))
      (assert (string= (format nil "~9,,,-2E" -1.2345689d3) "-.0012d+6"))
      (assert (string= (format nil "~9,,,-2E" 1.2345689d-3) ".00123d+0"))
      (assert (string= (format nil "~9,,,-2E" -1.2345689d-3) "-.0012d+0"))
      
      ;; Trac ticket #12:
      (assert (string= (format nil "~10,1,2,0,'*,,'DE" 1d-6) "   0.1D-05"))
      
      (assert (string= (format nil "~11f" 1.23456789123456789d-3) ".0012345679"))
      
      ;; Don't overflow
      (assert (string= (format nil "~12,,,,'%g" 1.2345678d1) "12.34568    "))
      
      ;; From CLH 22.3.11
      (defun test-f (x)
         (format nil "~6,2F|~6,2,1,'*F|~6,2,,'?F|~6F|~,2F|~F"
                 x x x x x x))
      
      (assert (string= (test-f 3.14159) "  3.14| 31.42|  3.14|3.1416|3.14|3.14159"))
      (assert (string= (test-f -3.14159) " -3.14|-31.42| -3.14|-3.142|-3.14|-3.14159" ))
      (assert (string= (test-f 100.0)  "100.00|******|100.00| 100.0|100.00|100.0"))
      (assert (string= (test-f 1234.0) "1234.00|******|??????|1234.0|1234.00|1234.0"))
      (assert (string= (test-f 0.006) "  0.01|  0.06|  0.01| 0.006|0.01|0.006"))
      
      
      
      (defun test-e (x)
          (format nil
                 "~9,2,1,,'*E|~10,3,2,2,'?,,'$E|~
                  ~9,3,2,-2,'%@E|~9,2E"
                 x x x x))
      
      
      (assert (string= (test-e 3.14159)  "  3.14e+0| 31.42$-01|+.003e+03|  3.14e+0"))
      (assert (string= (test-e -3.14159)  " -3.14e+0|-31.42$-01|-.003e+03| -3.14e+0"))
      (assert (string= (test-e 1100.0)  "  1.10e+3| 11.00$+02|+.001e+06|  1.10e+3"))
      (assert (string= (test-e 1100.0d0)  "  1.10d+3| 11.00$+02|+.001d+06|  1.10d+3"))
      (assert (string= (test-e 1.1e13)  "*********| 11.00$+12|+.001e+16| 1.10e+13"))
      (assert (string= (test-e 1.1d120)  "*********|??????????|%%%%%%%%%|1.10d+120"))
      
      (defun test-g (x)
         (format nil "~9,2,1,,'*G|~9,3,2,3,'?,,'$G|~9,3,2,0,'%G|~9,2G"
      	   x x x x))
      
      (assert (string= (test-g 0.0314159)  "  3.14e-2|314.2$-04|0.314e-01|  3.14e-2"))
      (assert (string= (test-g 0.314159)  "  0.31   |0.314    |0.314    | 0.31    "))
      (assert (string= (test-g 3.14159)  "   3.1   | 3.14    | 3.14    |  3.1    "))
      (assert (string= (test-g 31.4159)  "   31.   | 31.4    | 31.4    |  31.    "))
      (assert (string= (test-g 314.159)  "  3.14e+2| 314.    | 314.    |  3.14e+2"))
      (assert (string= (test-g 3141.59)  "  3.14e+3|314.2$+01|0.314e+04|  3.14e+3"))
      (assert (string= (test-g 3141.59d0)  "  3.14d+3|314.2$+01|0.314d+04|  3.14d+3"))
      (assert (string= (test-g 3.14e12)  "*********|314.0$+10|0.314e+13| 3.14e+12"))
      (assert (string= (test-g 3.14d120)  "*********|?????????|%%%%%%%%%|3.14d+120"))
      
      (defun test-scale (k)
        (format nil "~&Scale factor ~2D: |~13,6,2,VE|"
      	  (- k 5) (- k 5) 3.14159))
      
      (assert (string= (test-scale 0) "Scale factor -5: | 0.000003e+06|"))
      (assert (string= (test-scale 1) "Scale factor -4: | 0.000031e+05|"))
      (assert (string= (test-scale 2) "Scale factor -3: | 0.000314e+04|"))
      (assert (string= (test-scale 3) "Scale factor -2: | 0.003142e+03|"))
      (assert (string= (test-scale 4) "Scale factor -1: | 0.031416e+02|"))
      (assert (string= (test-scale 5) "Scale factor  0: | 0.314159e+01|"))
      (assert (string= (test-scale 6) "Scale factor  1: | 3.141590e+00|"))
      (assert (string= (test-scale 7) "Scale factor  2: | 31.41590e-01|"))
      (assert (string= (test-scale 8) "Scale factor  3: | 314.1590e-02|"))
      (assert (string= (test-scale 9) "Scale factor  4: | 3141.590e-03|"))
      (assert (string= (test-scale 10) "Scale factor  5: | 31415.90e-04|"))
      (assert (string= (test-scale 11) "Scale factor  6: | 314159.0e-05|"))
      (assert (string= (test-scale 12) "Scale factor  7: | 3141590.e-06|"))
      c7a4509f
  24. Jan 28, 2008
  25. Jan 24, 2008
    • rtoy's avatar
      Fix a format regression. (format nil "~21E" (expt 2d0 120)) was · 9877b8f6
      rtoy authored
      printing 1.0d+36.  It should have printed far more digits.
      
      The previous fixes weren't quite right.  We can't just adjust the
      scale factor with the size of the number.  The wrong number of digits
      gets printed.  So FLONUM-TO-STRING takes an extra parameter to
      indicate the exponent (base 10) of the number.  This is used to
      compensate for the output of FLONUM-TO-DIGITS so that we have the
      right number of digits.  (FLONUM-TO-STRING was assuming
      FLONUM-TO-DIGITS was called with a scaled number, but we weren't.)
      
      print.lisp:
      o FLONUM-TO-STRING takes extra parameter for the exponent (base 10) of
        the number---basically what ACCURATE-SCALE-EXPONENT would return.
      o Add FIXUP-FLONUM-TO-DIGITS to compensate the exponent returned by
        FLONUM-TO-DIGITS by the exponent of the number.
      o Some rearrange of the code to get the right number of digits printed
        under this new scheme.
      
      format.lisp:
      o Keep the exponent of the number and the scaled exponent separate so
        FLONUM-TO-STRING knows the real exponent.
      o FORMAT-GENERAL-AUX uses ACCURATE-SCALE-EXPONENT now instead of
        LISP:SCALE-EXPONENT.
      
      With these changes, the following tests all pass:
      
      (assert (string= (format nil "~9,3,2,0,'%G" 0.0314159) "0.314e-01"))
      (assert (string= (format nil "~9,3,2,-2,'%@e" 3.14159) "+.003e+03"))
      (assert (string= (format nil "~6,2,1,'*F" 3.14159) " 31.42"))
      (assert (string= (format nil "~9,0,6f" 3.14159) " 3141590."))
      
      (assert (string= (format nil "~9,4,,-7E" pi) ".00000003d+8"))
      (assert (string= (format nil "~9,4,,-5E" pi) ".000003d+6"))
      (assert (string= (format nil "~5,4,,7E" pi) "3141600.d-6"))
      (assert (string= (format nil "~11,4,,3E" pi) "  314.16d-2"))
      (assert (string= (format nil "~11,4,,5E" pi) "  31416.d-4"))
      (assert (string= (format nil "~11,4,,0E" pi) "  0.3142d+1"))
      (assert (string= (format nil "~9,,,-1E" pi) ".03142d+2"))
      (assert (string= (format nil "~,,,-2E" pi) "0.003141592653589793d+3"))
      (assert (string= (format nil "~,,,2E" pi) "31.41592653589793d-1"))
      (assert (string= (format nil "~E" pi) "3.141592653589793d+0"))
      (assert (string= (format nil "~9,5,,-1E" pi) ".03142d+2"))
      (assert (string= (format nil "~11,5,,-1E" pi) " 0.03142d+2"))
      (assert (string= (format nil "~G" pi) "3.141592653589793    "))
      (assert (string= (format nil "~9,5G" pi) "3.1416    "))
      (assert (string= (format nil "|~13,6,2,7E|" pi) "| 3141593.d-06|"))
      (assert (string= (format nil "~9,3,2,0,'%E" pi) "0.314d+01"))
      (assert (string= (format nil "~9,0,6f" pi) " 3141593."))
      (assert (string= (format nil "~6,2,1,'*F" pi) " 31.42"))
      (assert (string= (format nil "~6,2,1,'*F" (* 100 pi)) "******"))
      (assert (string= (format nil "~9,3,2,-2,'%@E" pi) "+.003d+03"))
      (assert (string= (format nil "~10,3,2,-2,'%@E" pi) "+0.003d+03"))
      (assert (string= (format nil "~15,3,2,-2,'%,'=@E" pi) "=====+0.003d+03"))
      (assert (string= (format nil "~9,3,2,-2,'%E" pi) "0.003d+03"))
      (assert (string= (format nil "~8,3,2,-2,'%@E" pi) "%%%%%%%%"))
      
      (assert (string= (format nil "~g" 1e0) "1.    "))
      (assert (string= (format nil "~g" 1.2d40) "12000000000000000000000000000000000000000.    "))
      
      (assert (string= (format nil "~e" 0) "0.0e+0"))
      (assert (string= (format nil "~e" 0d0) "0.0d+0"))
      (assert (string= (format nil "~9,,4e" 0d0) "0.0d+0000"))
      (assert (string= (format nil "~E" 1.234567890123456789d4) "1.2345678901234567d+4"))
      
      (assert (string= (format nil "~20E" (expt 2d0 120)) "1.32922799578492d+36"))
      (assert (string= (format nil "~21,8E" (expt 2d0 120)) "       1.32922800d+36"))
      
      
      (let (x)
       (dotimes (k 13 x)
        (setq x (cons (format nil "~%Scale factor ~2D: |~13,6,2,VE|"
                (- k 5) (- k 5) 3.14159) x))))
      9877b8f6
  26. Oct 09, 2007
    • rtoy's avatar
      If the number is exactly zero, make the printed exponent be zero, · d4d81f49
      rtoy authored
      independent of the scale factor.
      d4d81f49
    • rtoy's avatar
      o Make the implementation of the log approximation the same in · 3c06338d
      rtoy authored
        accurate-scale-exponent and flonum-to-digits.
      o Minor clean up of scale in both places.
      3c06338d
    • rtoy's avatar
      print.lisp: · 6ee52767
      rtoy authored
      o Add *POWERS-OF-TEN* for use in scaling.
      o Implement the fast log scaling from Burger and Dybvig's paper.
        Scaling is very noticeably faster for large and small numbers; it is
        somewhat slower for intermediate numbers near 1.  (Should we test
        for this case?)
      
      format.lisp:
      o Implement an accurate scaling routine, based on the scale routine in
        FLONUM-TO-DIGITS.
      o Use the new scaling routine in FORMAT-EXP-AUX.  This should fix Trac
        Ticket #12.
      6ee52767
  27. Oct 04, 2007
  28. Oct 03, 2007
    • rtoy's avatar
      Fix for Trac ticket #1. · 686a18ac
      rtoy authored
      Instead of having scale-exponent scale the number and using the scaled
      number for printing, have flonum-to-string scale the number for us.
      There is no loss in precision in flonum-to-string, so we don't have
      round-off errors in printing the number.  This means (format nil "~E"
      1.234567890123456789d4) is printed as "1.2345678901234567d+4" instead
      of "1.2345678901234565d+0".  Then prin1 and ~E both call
      flonum-to-digits with exactly the same number, so prin1 and ~E should
      have the same printed result.
      
      These tests pass:
      
      (assert (string= (format nil "~9,4,,-7E" pi) ".00000003d+8"))
      (assert (string= (format nil "~9,4,,-5E" pi) ".000003d+6"))
      (assert (string= (format nil "~5,4,,7E" pi) "3141600.d-6"))
      (assert (string= (format nil "~11,4,,3E" pi) "  314.16d-2"))
      (assert (string= (format nil "~11,4,,5E" pi) "  31416.d-4"))
      (assert (string= (format nil "~11,4,,0E" pi) "  0.3142d+1"))
      (assert (string= (format nil "~9,,,-1E" pi) ".03142d+2"))
      (assert (string= (format nil "~,,,-2E" pi) "0.003141592653589793d+3"))
      (assert (string= (format nil "~,,,2E" pi) "31.41592653589793d-1"))
      (assert (string= (format nil "~E" pi) "3.141592653589793d+0"))
      (assert (string= (format nil "~9,5,,-1E" pi) ".03142d+2"))
      (assert (string= (format nil "~11,5,,-1E" pi) " 0.03142d+2"))
      (assert (string= (format nil "~G" pi) "3.141592653589793    "))
      (assert (string= (format nil "~9,5G" pi) "3.1416    "))
      (assert (string= (format nil "|~13,6,2,7E|" pi) "| 3141593.d-06|"))
      (assert (string= (format nil "~9,3,2,0,'%E" pi) "0.314d+01"))
      (assert (string= (format nil "~9,0,6f" pi) " 3141593."))
      (assert (string= (format nil "~6,2,1,'*F" pi) " 31.42"))
      (assert (string= (format nil "~6,2,1,'*F" (* 100 pi)) "******"))
      (assert (string= (format nil "~9,3,2,-2,'%@E" pi) "+.003d+03"))
      (assert (string= (format nil "~10,3,2,-2,'%@E" pi) "+0.003d+03"))
      (assert (string= (format nil "~15,3,2,-2,'%,'=@E" pi) "=====+0.003d+03"))
      (assert (string= (format nil "~9,3,2,-2,'%E" pi) "0.003d+03"))
      (assert (string= (format nil "~8,3,2,-2,'%@E" pi) "%%%%%%%%"))
      
      (assert (string= (format nil "~g" 1e0) "1.    "))
      (assert (string= (format nil "~g" 1.2d40) "12000000000000000000000000000000000000000.    "))
      
      (assert (string= (format nil "~e" 0) "0.0e+0"))
      (assert (string= (format nil "~e" 0d0) "0.0d+0"))
      (assert (string= (format nil "~9,,4e" 0d0) "0.0d+0000"))
      (assert (string= (format nil "~E" 1.234567890123456789d4) "1.2345678901234567d+0"))
      686a18ac
  29. Jun 30, 2006
  30. May 01, 2006
    • rtoy's avatar
      code/format.lisp: · ef77f543
      rtoy authored
      o Add an additional case where we want to print out a trailing zero:
        There's no width constraint and the previous character was a decimal
        point, so the fraction to be printed is zero.
      
      code/print.lisp:
      o Honor the d option if we run out of room so (format nil "~,2f"
        0.001) produces "0.00", not "0.001".
      ef77f543
  31. Apr 28, 2006
  32. Nov 07, 2005
    • rtoy's avatar
      CLHS 22.3.3.2 says for ~E: · 3a8dc700
      rtoy authored
          If the parameter d is omitted, ... except that if the fraction to
          be printed is zero then a single zero digit should appear after
          the decimal point.
      
      Make it so.
      3a8dc700
  33. Aug 02, 2005
  34. Jun 30, 2005
  35. Jun 14, 2005
    • rtoy's avatar
      Some fixes for floating-point printing bugs reported by Bruno Haible, · 1031c478
      rtoy authored
      cmucl-imp, on or around 2005/06/13.
      
      Some useful tests:
      
      (format nil "~9,3,2,0,'%G" 0.0314159)
      Expected: "0.314e-01"
      
      
      (format nil "~9,3,2,-2,'%@e" 3.14159)
      Expected: "+.003E+03"
      
      
      (format nil "~6,2,1,'*F" 3.14159)
      Expected: " 31.42"
      
      (format nil "~9,0,6f" 3.14159)
      Expected: " 3141590."
      
      (let (x)
       (dotimes (k 13 x)
        (setq x (cons (format nil "~%Scale factor ~2D: |~13,6,2,VE|"
                (- k 5) (- k 5) 3.14159) x))))
      
      ("
      Scale factor  7: | 3141590.e-06|"
       "
      Scale factor  6: | 314159.0e-05|"
       "
      Scale factor  5: | 31415.90e-04|"
       "
      Scale factor  4: | 3141.590e-03|"
       "
      Scale factor  3: | 314.1590e-02|"
       "
      Scale factor  2: | 31.41590e-01|"
       "
      Scale factor  1: | 3.141590e+00|"
       "
      Scale factor  0: | 0.314159e+01|"
       "
      Scale factor -1: | 0.031416e+02|"
       "
      Scale factor -2: | 0.003142e+03|"
       "
      Scale factor -3: | 0.000314e+04|"
       "
      Scale factor -4: | 0.000031e+05|"
       "
      Scale factor -5: | 0.000003e+06|")
      
      
      code/format.lisp:
      o If the scale factor (k) is negative, the min number of digits to
        print is 1, not (- 1 k) because that prints too many if the field is
        too short.  Setting fmin to fdig is ok if k >= 0.  (See scale factor
        test above.)
      o If flonum-to-string returns with a trailing decimal point, we don't
        need to decrement spaceleft because that deletes a white-space
        character.  (See first scale factor 7 test above.)
      
      code/print.lisp:
      o We need to adjust the number of digits to be printed to include the
        scale factor.  See tests above.
      1031c478
  36. Apr 18, 2005
Loading