aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Easy Way to remember Ranges of 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 "Easy Way to remember Ranges of " Watch "Easy Way to remember Ranges of " New topic
Author

Easy Way to remember Ranges of

Steve Bartholomew
Greenhorn

Joined: Jul 18, 2005
Posts: 1
...Primitive values - any good tips

(eg - byte 8 bits, short 16 bits etc....)

any good websites / refreshers to help with converting bin to hex and so on?

Thanks!
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17259
    
    6

Well always remember that the signed primitives have one less positive value than negative.

For SCJP 5.0 you don't need to worry as much about this than say the 1.4 exam.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
K Bala
Greenhorn

Joined: Jul 14, 2005
Posts: 28
Steve,

Here is a formula to calculate the value range for primitive data types - byte to long.

Value Range = (-2^n-1) to (2^n-1)-1 where n is the size in bits.

So this is how it works.

Variable Type Size(in bits) Value
byte 8 (-2^7) - 2^7-1 (-128 to 127)
short 16 (-2^15) - 2^15-1(-32768 to 32767)
int 32 (-2^31) - 2^31-1
long 64 (-2^63) - 2^63-1


Quitters never win; Winners NEVER QUIT!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Easy Way to remember Ranges of