You're not playing with decimal values but rather with floating point numbers.

user> (type 0.1)
java.lang.Double

Floating point numbers have well known rounding errors when converting to decimal.
http://en.wikipedia.org/wiki/Floating_point#Accuracy_problems

you might want to use actual decimal numbers

user> (type 0.1M)
java.math.BigDecimal

user> (range 0.05M 0.16M 0.01M)
(0.05M 0.06M 0.07M 0.08M 0.09M 0.10M 0.11M 0.12M 0.13M 0.14M 0.15M)

hth,
Sacha

On 4/12/2010 15:42, Glen Rubin wrote:
If I use the range fn with a decimal number for step I get back
something like this:

(range 0.05 0.16 0.01)

user>  (0.05 0.060000000000000005 0.07 0.08 0.09 0.09999999999999999
0.10999999999999999 0.11999999999999998 0.12999999999999998
0.13999999999999999 0.15)

Really I want output more like i get from the following fn:

(map float (range 5/100 16/100 1/100))

user>  (0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15)


--
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

Reply via email to