I see- Sounds like we're on the same page. :)
---
Joseph Smith
j...@uwcreations.com
(402)601-5443
On Nov 30, 2009, at 11:14 AM, John Harrop wrote:
> On Mon, Nov 30, 2009 at 7:07 AM, Joseph Smith
> wrote:
> setScale returns a new BigDecimal with a given scale, it does not
> change the ori
On Mon, Nov 30, 2009 at 7:07 AM, Joseph Smith wrote:
> setScale returns a new BigDecimal with a given scale, it does not change
> the original value.
>
I did not claim otherwise. The effect of with-precision is like an implicit
(.setScale foo) around every BigDecimal "foo", only more efficient s
setScale returns a new BigDecimal with a given scale, it does not
change the original value.
e.g.)
user=> (def mybd (BigDecimal. 40))
#'user/mybd
user=> (.setScale mybd 4)
40.M
user=> mybd
40M
---
Joseph Smith
j...@uwcreations.com
(402)601-5443
On Nov 30, 2009, at 12:00 AM, John Harro
On Mon, Nov 30, 2009 at 12:22 AM, Joseph Smith wrote:
> What you want is to set the 'scale' of the BigDecimal.
>
> There doesn't seem to be a nice clojure macro for it, but this works:
>user=> (.setScale (reduce + [15.00M 15.01M 3.00M 3.01M]) 3)
>36.020M
>
That's what with-precision does
What you want is to set the 'scale' of the BigDecimal.
There doesn't seem to be a nice clojure macro for it, but this works:
user=> (.setScale (reduce + [15.00M 15.01M 3.00M 3.01M]) 3)
36.020M
---
Joseph Smith
j...@uwcreations.com
(402)601-5443
On Nov 29, 2009, at 2:02 PM, Gareth jo
Agh that makes sense, I thought I was going crazy but I guess it's
obvious now you point it out... Thanks for the help :D
Gaz
Sent from my iPhone
On Nov 29, 2009, at 10:36 AM, Ahmed Fasih wrote:
> Hi, without knowing much about what's going on, note that
>
> user=> (reduce + [15.00M 15.01M 3
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
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 obvi