• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Dan's question

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello
Long.toHexString (Long.MAX_VALUE)
How do you work out this answer ?
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Time is the best teacher, but unfortunately, it kills all of its students - Robin Williams. tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic