Thoughts on unified integer literal improvements
Bruce Chapman
brucechapman at paradise.net.nz
Wed Jul 1 01:45:15 PDT 2009
Max (Weijun) Wang wrote:
> "a new literal syntax for a literal whose type depends on the literal
> value".
>
> So, 0xFFu, being two bytes long, is always a byte? Then what does this
> line mean?
assuming you mean 2 nibbles long...
>
>>>>> int i = 0xFFu // 127 (should be 255);
> Or is this only Joe's 0xFFu? Your i will be -1?
Correct - with autosizing and leading zero (under consideration) you
could do it like this, forcing a zero high bit, making it nine bits
minimum and therefore the type of the hex literal would be short, that
would then widen to and int with value 255.
assert 255 = 0x0FFu
>
> Got it. I would prefer 0xFFy.
>
> How about a step further like --
>
> byte[] bs = 0x0102030405060708AABBCCDDEEFFy;
>
Thats a new array literal syntax, and not what is intended for coin.
>> I have been writing code doing low level protocol byte munging stuff
>> for years,
> Me too, http://hg.openjdk.java.net/jdk7/tl/jdk/rev/7360321c37e3
Ahh, ASN.1, is it a love/hate relationship for you? :)
Bruce
More information about the coin-dev
mailing list