Thoughts on unified integer literal improvements

Joseph D. Darcy Joe.Darcy at Sun.COM
Thu May 28 00:54:02 PDT 2009


Paul Benedict wrote:
> Thanks Mark :-) Then I believe the 'u' suffix is more straightforward.
>   

...and "u" is used in C to mean unsigned; although if I understand the C 
rules correctly, unsigned literals in C can only be assigned to unsigned 
variables.

With this proposal, Java would have unsigned int literals but only a 
*signed* int type.

-Joe

> I can mentally make the connection that 'u' means an 'unsigned'
> literal. I prefer that over any other letter suffix.
>
> byte b1 = 0xFFu; // you get -127
>
> Paul
>
> On Thu, May 28, 2009 at 2:35 AM, Mark Thornton wrote:
>   
>> Because 0xFF is equivalent to 255 which is outside the range of byte.
>> Compare with
>>
>> byte b1 = 0xFFFFFFFF;
>>
>> It is a consequence of the (unfortunate) choice of bytes as signed.
>>
>> Mark
>>
>> Paul Benedict wrote:
>>     
>>> byte b1 = 0xFF;
>>> byte b2 = 3;
>>>
>>> Can someone explain to me why this shouldn't straight compile?
>>>       
>
>   




More information about the coin-dev mailing list