12. NUMBERS AND DATA

Topics:

• Number bases; binary, octal, decimal, hexadecimal

• Binary calculations; 2s compliments, addition, subtraction and Boolean operations

• Encoded values; BCD and ASCII

• Error detection; parity, gray code and checksums

Objectives:

• To be familiar with binary, octal and hexadecimal numbering systems.

• To be able to convert between different numbering systems.

• To understand 2s compliment negative numbers.

• To be able to convert ASCII and BCD values.

• To be aware of basic error detection techniques.

Base 10 (decimal) numbers developed naturally because the original developers (probably) had ten fingers, or 10 digits. Now consider logical systems that only have wires that can be on or off. When counting with a wire the only digits are 0 and 1, giving a base 2 numbering system. Numbering systems for computers are often based on base 2 numbers, but base 4, 8, 16 and 32 are commonly used. A list of numbering systems is give in Figure 12.1 Numbering Systems. An example of counting in these different numbering systems is shown in Figure 12.1 Numbers in Decimal, Binary, Octal and Hexadecimal.

 

Figure 12.1 Numbering Systems

 

Figure 12.1 Numbers in Decimal, Binary, Octal and Hexadecimal

The effect of changing the base of a number does not change the actual value, only how it is written. The basic rules of mathematics still apply, but many beginners will feel disoriented. This chapter will cover basic topics that are needed to use more complex programming instructions later in the book. These will include the basic number systems, conversion between different number bases, and some data oriented topics.