Clojure

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

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Trivial Trivial
  • Resolution: Completed
  • Affects Version/s: Release 1.3, Release 1.4
  • Fix Version/s: Release 1.5
  • Component/s: None
  • Labels:
    None
  • Environment:
    Linux 2.6.31-22-generic #61-Ubuntu SMP Wed Jul 28 01:57:06 UTC 2010 i686 GNU/Linux
  • Patch:
    Code and Test
  • Approval:
    Ok

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.

  1. clj-881-cl-format-exception-patch2.txt
    26/Mar/12 5:04 PM
    3 kB
    Andy Fingerhut
  2. patchfile
    20/Nov/11 2:47 AM
    3 kB
    Vyacheslav Dimitrov

Activity

People

Vote (1)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: