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 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.