On Jul 16, 2009, at 10:13 AM, flodel wrote:

I have a Clojure script that reads numbers in a normal format like
0.0000012, but after processing, returns in a scientific format, for
example, 8.03E-6

Is there a way to turn this scientific notation off?

Numbers are stored internally in a binary format. Clojure prints them using formatting that's determined by the output stream. It defaults to using scientific notation for some ranges of floating point numbers. If you want more control about how the numbers are output, you have some options including the clojure.core functions format and printf, and clojure.contrib.pprint functions such as and cl-format pprint.

Here's an example using format:

user=> (doc format)
-------------------------
clojure.core/format
([fmt & args])
Formats a string using java.lang.String.format, see java.util.Formatter for format
  string syntax
nil
user=> (format "%s %f %.4f %.8f" 8.3e-6 8.3e-6 8.3e-6 8.3e-6)
"8.3E-6 0.000008 0.0000 0.00000830"
user=>

--Steve

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to