Joel Gluth <joel.gl...@gmail.com> writes:

>> And usually, you should refrain from using floating points at all, no
>> matter if BigDecimal or Double.
>
> I thought BigDecimal with was not a floating point in the traditional
> sense (ie., subject to all of the usual rounding horror, unless you
> ask it to be)? That is, you can do decimal calculations exactly using
> it.

You are right.  What I've meant that you don't want to use double or
float because it's not precise, and you don't want to use BigDecimal
because it's slower and, even more important, it'll throw an exception
if a given number cannot be represented as decimal number.

user=> (/ 1M 3)
ArithmeticException Non-terminating decimal expansion; no exact
representable decimal result.  java.math.BigDecimal.divide
(BigDecimal.java:1616)

So the general suggestion is to stick to integers and rational numbers
as long as possible.

Bye,
Tassilo

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