Difference parsing from String and byte literal

Vimil Saju vimilsaju at yahoo.com
Sat Apr 9 22:59:51 PDT 2011


Yeah.. that 'l' does look like a '1' 

--- On Sat, 4/9/11, Dr Heinz M. Kabutz <heinz at javaspecialists.eu> wrote:

> From: Dr Heinz M. Kabutz <heinz at javaspecialists.eu>
> Subject: Re: Difference parsing from String and byte literal
> To: "Vimil Saju" <vimilsaju at yahoo.com>
> Cc: coin-dev at openjdk.java.net, carsten.zerbst at groy-groy.de
> Date: Saturday, April 9, 2011, 10:44 PM
> 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
> 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
> <carsten.zerbst at groy-groy.de>
> wrote:
> > 
> >   
> >> From: carsten.zerbst at groy-groy.de
> <carsten.zerbst at groy-groy.de>
> >> Subject: Difference parsing from String and byte
> literal
> >> To: 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