On 07/31/2011 03:33 PM, Mark Murphy wrote:
> On Sun, Jul 31, 2011 at 9:13 AM, Olivier Guilyardi <l...@samalyse.com> wrote:
>> How comes Resources.getColor() returns an int? This can't hold the maximum 
>> value
>> of 0xFFFFFFFF because Java int is signed.
> 
> An int can hold 0xFFFFFFFF, because an int is 32 bits, and 0xFFFFFFFF
> is a 32-bit value. From a mathematics perspective, 0xFFFFFFFF is a
> negative number in Java.

I know it's 32bit, but using a signed int to hold a value higher that 0x7FFFFFFF
seems like perverting the sign bit IMO. It can lead to subtle bugs. Maybe it's a
common case for Java programmers but it would be cleaner to use a long I think,
since there is no unsigned integers available.

--
  Olivier

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to