Decimal Number System
Overview - Number Systems
Probably the biggest stumbling block most beginning programmers encounter when attempting to learn assembly language is the common use of the binary and hexadecimal numbering systems. Understanding these numbering systems is important because their use simplifies other complex topics including boolean algebra and logic design, signed numeric representation, character codes, and packed data.
This section discusses several important concepts including the binary, decimal, and hexadecimal numbering systems, binary data organization (into bits, nibbles, bytes, words, and double words), signed and unsigned number systems, arithmetic, logical, shift, and rotate operations on binary values, bit fields and packed BCD (Binary Coded Decimal) data, and the ASCII (American Standard Code for Information Interchange) character set. This is basic material and the remainder of this tutorial depends upon your understanding of these concepts. If you are already familiar with these terms from other courses or study, you should at least skim this material before proceeding to the next chapter. If you are unfamiliar with this material, or only vaguely familiar with it, you should study it carefully before proceeding. All of the material in this chapter is important! Do not skip over any material.
Most modern computer systems do not represent numeric values using the decimal system. Instead, they typically use a binary or two's complement numbering system. To understand the limitations of computer arithmetic, you must understand how computers represent numbers.
Remember how mathematical operations are entered into a computer:
- + is used for addition
- - is used for subtraction
- * is used for multiplication
- / is used for division
- ^ is used to raise to a power
There are four number bases commonly used in programming. These are:
Name | Base | Symbol |
Binary | Base 2 | B |
Octal | Base 8 | Q or O |
Decimal | Base 10 | none or D |
Hexadecimal | Base 16 | H |
The Decimal Number Base Systems
The Decimal Number System uses base 10. It includes the digits from 0 through 9. The weighted values for each position is as follows:
10^4 | 10^3 | 10^2 | 10^1 | 10^0 | 10^-1 | 10^-2 | 10^-3 |
10000 | 1000 | 100 | 10 | 1 | .1 | .01 | .001 |
You have been using the decimal (base 10) numbering system for so long that you often take it for granted. When you see a number like "123", you don't think about the value 123. Instead, you generate a mental image of how many items this value represents. In reality, however, the number 123 represents:
- 1 * 10^2 + 2 * 10^1 + 3 * 10^0 =1 * 100 + 2 * 10 + 3 * 1 =100 + 20 + 3 =123
Each digit appearing to the left of the decimal point represents a value between zero and nine times power of ten represented by its position in the number. Digits appearing to the right of the decimal point represent a value between zero and nine times an increasing negative power of ten. For example, the value 725.194 is represented as follows:
- 7 * 10^2 + 2 * 10^1 + 5 * 10^0 + 1 * 10^-1 + 9 * 10^-2 + 4 * 10^-3 =7 * 100 + 2 * 10 + 5 * 1 + 1 * 0.1 + 9 * 0.01 + 4 * 0.001 =700 + 20 + 5 + 0.1 + 0.09 + 0.004 =725.194
No comments:
Post a Comment