Thoughts on unified integer literal improvements

Reinier Zwitserloot reinier at zwitserloot.com
Mon Jun 29 03:00:13 PDT 2009


0xFFu is 127?

I hope that was a typo and you meant to write 256.

  --Reinier Zwitserloot



On 2009/29/06, at 11:56, Weijun Wang wrote:

>> long ell = 0xFFFFFFFFu; // A positive long value
>
> Any particular requirement here? Why not simply
>
>   long ell = 0xFFFFFFFFl;
>
>>
>> I think this approach has some advantages over the "y" suffix; in
>> particular I think it gives more desirable behavior in cases like  
>> this:
>>
>> byte b = 0xFFy // a negative byte value
>> byte b = 0xFFu // also a negative byte value
>>
>> short s = 0xFFy // a negative short value, -128;
>>                 // byte value is signed extended
>> short s = 0xFFu // a positive short value, +127
>>
>> int   i = 0xFFy // -128
>> int   i = 0xFFu // 127
>
> Does this mean the actual value of 0xFFu is determined by looking at  
> the
> LHS of the assignment? This is terrible.
>
> I'd rather use something like 0bXX which is itself always a byte  
> literal.
>
> Max
>
>>
>> -Joe
>>
>




More information about the coin-dev mailing list