Probably more of a java question, but I'm finding that floating point 
formats with (format) are inflating data sizes enormously with meaningless 
trailing zeros, because the underlying java conversion methods don't work 
as they do on other platforms.

E.g., in C
printf("%.6g %.6g %.6g %.6g\n", 0.000001, 100.00001, 100000.0, 1000000.0)

gives
1e-06 100 100000 1e+06

in python:

>>> "%.6g %.6g %.6g %.6g" % (0.000001, 100.00001, 100000.0, 1000000.0)
'1e-06 100 100000 1e+06'



while clojure will produce this:

> (format "%.6g %.6g %.6g %.6g" 0.000001, 100.00001, 100000.0, 1000000.0)
"1.00000e-06 100.000 100000 1.00000e+06"

The desired behavior is to set the max significant digits & get the minimal 
decimal representation. I've been through docs for Formatter, NumberFormat, 
and others, but can't find anything that both 1) supports setting 
significant digits (vs. fractional digits), and 2) doesn't pad meaningless 
zeros on the end.

Is there a standard solution?

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to