wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Bit depth - What does it really means? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Bit depth - What does it really means?" Watch "Bit depth - What does it really means?" New topic
Author

Bit depth - What does it really means?

Vasco Dion�sio
Greenhorn

Joined: Dec 04, 2003
Posts: 22
Could someone explain to me what exactly does the concept of "Bit Depth" means?
For instance:
A primitive type "char" has 16 bit (unsigned) so I can use 2^16 possible combinations (65536);
if a "byte" has 8 bits (signed) it means the first bit indicates if the value is positive or negative, right? So, I get 7 bits to the absolute numerical value. What is the bit depth of a "byte"? 7 or 8?
Thanks a lot...
Ray Stojonic
Ranch Hand

Joined: Aug 08, 2003
Posts: 326
I googled bit depth, it is the number of bits used to store information about each pixel in a computer image, I wouldn't worry to much about it terms of Java
Vasco Dion�sio
Greenhorn

Joined: Dec 04, 2003
Posts: 22
First off all thanks for your answer...
Neverthless, I think that's only one of the meanings of the expression, because I believe it also means the number of bits available for computing the range of numerical combinations in a primitive type in Java, am I right?
My question concerns more with the last meaning...
Thanks anyway for your help...
Ray Stojonic
Ranch Hand

Joined: Aug 08, 2003
Posts: 326
hmmm
(more googling)
.
.
.
A quick scan of the results tells me that 99% of the time, bit depth refers to number of bits used to describe a pixel.
However, the one exception I found refered to bit depth as the size of a container, in bits; which makes sense, given the first explanation.
So, you could say that the bit depth of a byte is 8, but I think people will understand you better if you stick with the tried and true: 'a byte is 8 bits'.
Ben McElyea
Greenhorn

Joined: Oct 05, 2003
Posts: 1
There are 8 bits to a byte. A byte has 256 possible values
a bit is a 1 or 0.

To convert from decimal to binary you just "turn on" one of the zeros
So a byte with the value of 00000001 is 1, 00000011 is 2, 00000100 is 4,
01100000 is 64+32 = 96 , 11111111 would be 128+64+32+16+8+4+2+1 = 255. When it is signed the bit at the decimal 128 place is used to either show positive or negative. So the max value a signed byte can have is 127:
011111111 or 64+32+16+8+4+2+1 = 127
111111111 or 64+32+16+8+4+2+1 = -127
[ December 19, 2003: Message edited by: Ben McElyea ]
Vasco Dion�sio
Greenhorn

Joined: Dec 04, 2003
Posts: 22
Thank you both
Michael Sullivan
Ranch Hand

Joined: Dec 26, 2003
Posts: 235
While reviewing the Osbourne Java2 SCJP/ SCJD book, bit depth refers the not only the number if bits in each primitive, but also the range of values that you might expect. For instance:
literal ranges for the exam. To calculate the range of a number, you use the following formula

-2 to the power of (bits-1) = negative range
2 to the power of (bits-1)-1 = positive range

the positive is one less than the negative because the zero is stored as a positve binary number.

TYPE.....BITS.....BYTES.....Possibilites

byte.....8........1.........256
short....16.......2.........> 60,000
int......32.......4.........> 4 billion
long.....64.......8
float....32.......4.........> 60,000
double...64.......4

Where I see this mostly tested (in the osbourne book) is when the code tries to implicitly cast into another type... so if you know that a char is really a 16bit unsigned integer, you know that it can be implicitly cast into int.
[ December 26, 2003: Message edited by: Michael Sullivan ]
[ December 26, 2003: Message edited by: Michael Sullivan ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Bit depth - What does it really means?
 
Similar Threads
converting C++ type struct to Java class?
Doubt regarding ~BITWISE NOT
Signed and unsigned confusion
Conversion of Primitives
signed bits...