L.2. Bit Manipulation and the Bitwise Operators

Computers represent all data internally as sequences of bits. Each bit can assume the value 0 or the value 1. On most systems, a sequence of eight bits forms a byte—the standard storage unit for a variable of type byte. Other types are stored in larger numbers of bytes. The bitwise operators can manipulate the bits of integral operands (i.e., operations of type byte, char, short, int and long),but not floating-point operands.

Note that the discussions of bitwise operators in this section show the binary representations of the integer operands. For a detailed explanation of the binary (also called base 2)number system, see Appendix E, Number Systems.

The bitwise operators are bitwise AND (&),

Get Java™ How to Program, Seventh Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.