Uploaded image for project: 'Clojure'
  1. CLJ-881

Problem with the "cl-format" function from the clojure.pprint

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Trivial
    • Resolution: Completed
    • Affects versions: Release 1.4, Release 1.3
    • Fix versions: Release 1.5
    • Labels:
      None
    • Environment:

      Linux 2.6.31-22-generic #61-Ubuntu SMP Wed Jul 28 01:57:06 UTC 2010 i686 GNU/Linux

    • Approval:
      Ok
    • Patch:
      Code and Test

      Description

      Let's see the following scenario:

      vdim@home:~/clojure$ git log -1
      commit ba930d95fc3a4a78c5bd6756ea483c9dac681618
      Author: Rich Hickey <richhickey@gmail.com>
      Date: Sun Oct 30 10:44:55 2011 -0400

      inline equiv in variadic =
      vdim@home:~/clojure$ rlwrap java -cp clojure-1.4.0-master-SNAPSHOT.jar clojure.main
      Clojure 1.4.0-master-SNAPSHOT
      user=> (use 'clojure.pprint)
      nil
      user=> (cl-format nil "~12,10F" 1.00000000074)
      "1.0000000007"
      user=> (cl-format nil "~12,10F" 1.00000000076)
      NumberFormatException For input string: "10000000007" java.lang.NumberFormatException.forInputString (NumberFormatException.java:65)
      user=>

      The exception is caused from round-str function (cl-format.clj) where
      my number (100000000076) is coerced to an Integer (see line with Integer/valueOf code
      into this function).

      Is this normal behaviour?

      See patch with tests and my suggestion for solving this problem.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              alex+import import
            • Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: