On Mon, Mar 25, 2013 at 3:24 PM, Jim foo.bar <jimpil1...@gmail.com> wrote:

> On 25/03/13 15:22, Ben Wolfson wrote:
>
>> The 94th fibonacci number is greater than Long/MAX_VALUE, so it
>> overflows. It is using longs.
>>
>
> I see....shouldn't Clojure auto-promote it to a BigInt then?


It doesn't by default.

There are two options:

a) artithmetic is polymorphic, and given a bigint argument, will use bigint
arithmetic, so use 0N as suggested.

b) use the auto-promoting arithmentic forms: +'  -'  *'  inc'  etc.

Clojure used to do auto-promotion, but it is off by default now as it has a
significant performance impact.  In Java, a slot can either be a primitive
or an object, so the auto-promoting forms are forced to box primitive
objects in java.lang.Long wrappers.

-- 
-- 
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/groups/opt_out.


Reply via email to