G.4. Representing Integers
Integer data types in Java represent signed integer values, that is, both positive and negative integer values. The values of char type can effectively be regarded as unsigned 16-bit integers.
Values of type byte are represented as shown in Table G.2. A value of type byte requires 8 bits. With 8 bits, we can represent 28 or 256 values. Java uses 2's complement (explained later) to store signed values of integer data types. For the byte data type, this means values are in the range –128 (–27) to +127 (27–1), inclusive.
Bits in an integral value are usually numbered from right to left, starting with the least significant bit 0 (also called the right-most bit). When applying bitwise operators, the number of the most significant ...
Get Programmer's Guide to Java™ Certification, A: A Comprehensive Primer, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.