Difference parsing from String and byte literal

Rich Midwinter rich.midwinter at gmail.com
Sun Apr 10 14:37:43 PDT 2011


Wouldn't it being illegal just for binary literals be confusingly
inconsistent? Ideal as it is.

KR
Rich


On 10 April 2011 22:02, Dr Heinz M. Kabutz <heinz at javaspecialists.eu> wrote:

> +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