File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Dan's question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Dan Watch "Dan New topic
Author

Dan's question

jioy uilo
Greenhorn

Joined: Mar 29, 2003
Posts: 25
Hello
Long.toHexString (Long.MAX_VALUE)
How do you work out this answer ?
Lawrence Chettiar
Ranch Hand

Joined: Apr 10, 2003
Posts: 62
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


SCJP 1.4 (86%)<br />SCMAD Beta (77%)<br />SCEA (part I:89%,partII:93%)<br />MCAD (cleared 70-315 & 70-320 [Score 980])
Dan Chisholm
Ranch Hand

Joined: Jul 02, 2002
Posts: 1865
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.


Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="http://www.danchisholm.net/" target="_blank" rel="nofollow">Try my mock exam.</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dan's question