Well, here's a recap of what your textbook should be telling you.
As Shyam's post indicates, range limits are not simply a "number of digits." Instead, the first thing to consider is the amount of
memory that each type is allotted.
NUMERIC INTEGRALS...
byte: 8 bits
short: 16 bits
int: 32 bits
long: 64 bits
NUMERIC FLOATING POINT...
float: 32 bits
double: 64 bits
SPECIAL CASES...
char: 16 bits
boolean: 1 bit
Once you know this, the next step is to understand how values are represented in binary for each type.
In Java,
all numeric primitive types are signed, meaning that they can represent both positive and negative values. The first bit is sometimes called the "sign bit." If this is 1, then the value is negative. If it's 0, then the value is non-negative.
Let's consider byte as an example. A byte is 8 bits, and 8 zeros represents a value of zero: 00000000. The positive values are straightforward binary...
0 => 00000000
1 => 00000001
2 => 00000010
3 => 00000011
...
126 => 01111110
127 => 01111111
For negative values, consider what -1 should look like in binary. When we add +1 to it, we should get zero. So -1 is represented by all ones: 11111111. (Thus, -1 + 1 is 11111111 + 00000001 = 00000000.)
In general, "increasing" the binary representation of a negative value moves that value towards zero. So the minimum negative value is a one followed by all zeros. In the case of byte, this is 10000000, representing -128...
-128 => 10000000
-127 => 10000001
-126 => 10000010
...
-2 => 11111110
-1 => 11111111
Therefore, the range of an 8-bit byte is -128 to 127, which is
-2^7 to (-2^7) - 1. Notice that the range of positive values is one less than the range of negative values because zero is
non-negative (having a leading bit of of 0).
Ranges for the other numeric integral types follow this same
pattern.
Floating-point values are stored quite differently, according to a standard called "IEEE 754." This is a topic unto itself (best addressed by searching the web for "IEEE 754"), but some key points are as follows. As with the integral numerics, floating-point numerics use the leading bit to indicate the sign. The remaining bits store the value in a scientific notation format, with an "exponent" value and a "mantissa" value. This provides for tremendous range with a "sliding window" of precision. For this reason, floating-point values should be considered
approximations. (See
this thread for a more detailed illustration,
this page for a nice explanation, and bookmark the essential,
Some things you should know about floating-point arithmetic.)
A 16-bit char is much like an integral primitive, except that its values are all non-negative. Thus, the numeric range for a char is
0 to (2^16) - 1. How these values translate to symbols is another topic. (For most common characters, see this
ACSII table.)
Finally, a single-bit boolean is restricted to values of true or false.