Hi, without knowing much about what's going on, note that

user=> (reduce + [15.00M 15.01M 3.00M 3.01M])
36.02M
user=> (with-precision 3 (reduce + [15.00M 15.01M 3.00M 3.01M]))
36.0M

So an intermediate step in the calculation is rounded down to 3
decimals and that rounding error is carried through. So the "9M" with
3-precision would mean "9.00M".

Amazing! It might be getting in your way here, but functions changing
their operation because they were called via "with-precision" speaks
to a flexibility that I've only seen in Lisps.

On Nov 28, 10:27 pm, Gaz <gareth.e.jo...@gmail.com> wrote:
> Hi, apologies if this is a silly question. Im having some confusion
> with the following code:
>
> (with-precision 3 (/ 36.02M 4.00M))
> 9.01M
>
> This is what i would expect. This however:
>
> (with-precision 3 (/ (reduce + [15.00M 15.01M 3.00M 3.01M])
> 4.0M))
> 9M
>
> Seems a bit odd? Or am I missing something obvious :(
>
> Thanks for any help.

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