Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dan's question

 
jioy uilo
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
Long.toHexString (Long.MAX_VALUE)
How do you work out this answer ?
 
Lawrence Chettiar
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now you know that the Long.MAX_VALUE is a max postive no that means all the bit will be 1 except the MSB (most significant bit) so you know only 1st bit is zero rest is 1. Now how may bits are in Long (64) i.e in hex we have 64/4 (one hex digit will use 4 bits) so you have 16 hex digits now all the but first will not be f as four 1111(bits) will be f.
So will have 15 f's vis(fffffffffffffff)
now for the left 4 bits which are 0111 which is
7 in hex so the end value will be
7fffffffffffffff (7 and 15 f's)
Well this is my way of calculating hope this help you
 
Dan Chisholm
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Lawrence.
jioy,
Your question is frequently asked so I put the answer on a Maximum Value Tutorial page. The Base Conversion Tutorial might also be helpful.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic