Difference parsing from String and byte literal

Dr Heinz M. Kabutz heinz at javaspecialists.eu
Sun Apr 10 14:02:18 PDT 2011


+l

Regards

Heinz
-- 
Dr Heinz M. Kabutz (PhD CompSci)
Author of "The Java(tm) Specialists' Newsletter"
Sun Java Champion
IEEE Certified Software Development Professional
http://www.javaspecialists.eu
Tel: +30 69 72 850 460
Skype: kabutz 



On 4/10/11 5:52 PM, Neal Gafter wrote:
> Actually, since the binary literal is new, this is an opportunity to 
> make the small letter l at the end illegal.
>
> On Sat, Apr 9, 2011 at 10:44 PM, Dr Heinz M. Kabutz 
> <heinz at javaspecialists.eu <mailto:heinz at javaspecialists.eu>> wrote:
>
>     Please use capital L, especially for a binary number!
>
>     long coin = 0b10000000_00000000_00000000_10000000L;
>
>
>     Regards
>
>     Heinz
>     --
>     Dr Heinz M. Kabutz (PhD CompSci)
>     Author of "The Java(tm) Specialists' Newsletter"
>     Sun Java Champion
>     IEEE Certified Software Development Professional
>     http://www.javaspecialists.eu
>     Tel: +30 69 72 850 460 <tel:%2B30%2069%2072%20850%20460>
>     Skype: kabutz
>
>
>
>     On 4/9/11 11:47 PM, Vimil Saju wrote:
>     > Shouldn't you use
>     > long coin = 0b10000000_00000000_00000000_10000000l;
>     > ?
>     >
>     >
>     > --- On Sat, 4/9/11, carsten.zerbst at groy-groy.de
>     <mailto:carsten.zerbst at groy-groy.de> <carsten.zerbst at groy-groy.de
>     <mailto:carsten.zerbst at groy-groy.de>> wrote:
>     >
>     >
>     >> From: carsten.zerbst at groy-groy.de
>     <mailto:carsten.zerbst at groy-groy.de> <carsten.zerbst at groy-groy.de
>     <mailto:carsten.zerbst at groy-groy.de>>
>     >> Subject: Difference parsing from String and byte literal
>     >> To: coin-dev at openjdk.java.net <mailto:coin-dev at openjdk.java.net>
>     >> Date: Saturday, April 9, 2011, 12:59 PM
>     >> Hello,
>     >>
>     >> I played a little with the new JDK7 and run into a
>     >> inconsistency with
>     >> existing code.
>     >>
>     >> So far I use the following code to represent a mask
>     >>
>     >>   long SOURCE_ENTITY_TYPE_MASK =
>     >> Long.parseLong("10000000" + //
>     >>
>     >>    "00000000" + //
>     >>
>     >>    "00000000" + //
>     >>
>     >>    "10000000", 2);
>     >>
>     >> Ok, the shiny new version would be
>     >>
>     >> long coin = 0b10000000_00000000_00000000_10000000;
>     >>
>     >> But if one print the decimal and binary representation one
>     >> gets a difference
>     >>
>     >> from String 2147483776
>     >> from String
>     >>
>     >> 10000000000000000000000010000000
>     >> binary -2147483520
>     >> binary
>     >> 1111111111111111111111111111111110000000000000000000000010000000
>     >>
>     >>
>     >> This is no problem for my mask but should perhaps be
>     >> mentioned in the
>     >> tutorial ?
>     >>
>     >> Bye, Carsten
>     >>
>     >>
>     >>
>     >
>     >
>     >
>
>



More information about the coin-dev mailing list