A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
this week in the
Programmer Certification (SCJP/OCPJP)
Easy Way to remember Ranges of
Joined: Jul 18, 2005
Jul 18, 2005 03:43:00
...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?
Joined: Feb 05, 2001
Jul 18, 2005 09:33:00
Well always remember that the signed primitives have one less positive value than negative.
5.0 you don't need to worry as much about this than say the 1.4 exam.
Perfect World Programming, LLC
Two Laptop Bag
How to Ask Questions the Smart Way FAQ
Joined: Jul 14, 2005
Jul 18, 2005 12:19:00
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:
subject: Easy Way to remember Ranges of
Question regarding shift operator?
Unsigned rightshifting int -1
Interesting >>> operation
JSP shows code
Why bitwise operators can be used in boolean expressions?
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014