java - Value of 1024 has one bit more in binary representation that value of 1 -


the output of following code:

system.out.println( long.tobinarystring( double.doubletorawlongbits( 1 ) ) ); system.out.println( long.tobinarystring( double.doubletorawlongbits( 1024 ) ) ); 

is:

11111111110000000000000000000000000000000000000000000000000000 100000010010000000000000000000000000000000000000000000000000000 

why code prints 1 bit more value of 1024?

why code prints 1 bit more value of 1024?

this because leading 000000's dropped long.tobinarystring. double 64-bit, can have 63 leading zeros.

e.g. 000000000000000000000000000000000000000000000000000000000000000000000001 printed 1


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -