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
Post a Comment