Hi Rich,

2009/8/19 Rich Hickey <richhic...@gmail.com>:
>
> On Fri, Aug 14, 2009 at 6:28 AM, David Powell<djpow...@djpowell.net> wrote:
>>
>>
>>> user=> (.getClass (+ 1 Integer/MAX_VALUE))
>>> java.lang.Long
>>
>> Also,
>>
>> user=> (def i (Integer/MAX_VALUE))
>>
>> user=> (class (+ 1 i))
>> java.lang.Long
>>
>> user=> (class (inc i))
>> java.math.BigInteger
>>
>> I'd expect inc to overflow to a Long rather than a BigInteger.
>>
>
> Issue/patch welcome for this.

I've got a fix for Integers overflowing to BigIntegers rather than
Longs. I guess I should create a new issue in Assembla for it.

I'm uncertain whether you feel that (inc Integer/MAX_VALUE) throwing
is a bug or not? Like Mike said, Integer/MAX_VALUE is treated as a
primitive int so the behaviour is the same as when we cast a number to
int:

user> (def i Integer/MAX_VALUE)
#'user/i
user> (inc (int i))
; Evaluation aborted. (java.lang.ArithmeticException: integer overflow)
user> (inc Integer/MAX_VALUE)
; Evaluation aborted. (java.lang.ArithmeticException: integer overflow)

So the behaviour is consistent as long as one realises the difference
between, e.g. 1 and (int 1).

> Rich

-- 
  ! Lauri

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