Java Tutorials - Herong's Tutorial Notes
Dr. Herong Yang, Version 6.00

What Are Bits and Bytes

This section describes bits and bytes as data storage units and as data types.

Bit - The smallest storage unit in the computer world. It can only hold two possible values: 0 and 1.

Bit - The smallest unit of measure of digital information size.

Bit - A single digit of a binary number. It can only have two possible values: 0 and 1.

Byte - A storage unit with 8 bits. A byte can hold 256 possible values.

Byte - A unit of measure of digital information size. 1 byte = 8 bits. For example, a Java source code file, Hello.java, has a size of 109 bytes.

Byte - A data type in many programming language. It can be used to store 256 possible integer values. In Java, 'byte' is a primitive data type that can store an integer value in the range of -128 and 127.

Sections in This Chapter

What Are Bits and Bytes

"byte" Data Type and Implicit Casting

Operations on "byte" Data Type Values

Bitwise Operations on "byte" Values

Bitwise Operations on "byte" Values - Example Program

Shift Operations - Left, Right or Unsigned Right Shift

Dr. Herong Yang, updated in 2008
What Are Bits and Bytes