Difference parsing from String and byte literal

Vimil Saju vimilsaju at yahoo.com
Sat Apr 9 13:47:41 PDT 2011


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