4. 2.1 Introduction
4
Computer systems operate using two voltage
levels (usually 0 volt and +5 volt).
With two such levels, we can represent exactly
two different values, zero and one.
All kinds of information processed by the
computer are expressed using only these two
values.
5. 2.2 Numbering Systems
2.2.1 Overview of the Decimal Numbering System
5
We use the decimal system, also called base 10, because
we have ten fingers.
In decimal, a numeric quantity is represented by a series
of digits from 0 to 9.
6. 2.2 Numbering Systems
2.2.2 The Binary Numbering System
6
The binary numbering system is a base 2 numbering
system.
A “binary digit” is called a bit.
7. 2.2 Numbering Systems
2.2.2 The Binary Numbering System
7
Four bits can represent 16 different values.
If we use them to represent unsigned integers,
we obtain the range 0 (0000) to 15 (1111).
In general, n bits can represent the 2n unsigned
integers 0 to 2n-1.
For example 8 bits (one byte) can represent the
numbers from 0 (00000000) to 255 (11111111).
8. 2.2 Numbering Systems
2.2.2 The Binary Numbering System
8
2.2.2.1 Conversions between Binary and Decimal Systems
write successive powers of 2 over each digit from
right to left and add up those numbers that are
under a 1.
9. 2.2 Numbering Systems
2.2.2 The Binary Numbering System
9
2.2.2.1 Conversions between Binary and Decimal Systems
To convert from decimal to binary, divide the
number by two. The remainder (which will be
either 0 or 1) is the rightmost binary digit.
10. 2.2 Numbering Systems
2.2.3 Hexadecimal Numbering System
10
Hexadecimal numbers have two advantages:
they are very compact (short) and it is simple to
convert them to binary and vice versa. Since the
base of a hexadecimal number is 16, each
hexadecimal digit can represent one of sixteen
values between 0 and 15.
12. 2.2 Numbering Systems
2.2.3 Hexadecimal Numbering System
12
2.2.3.2 Binary to Hexadecimal Conversion
As you can see,
hexadecimal numbers
are compact and easy to
read.
In addition, you can easily
convert between
hexadecimal and binary
using the table.
13. 2.3 Binary Logic
2.3.1 Overview
13
Binary logic is used to build the decision-making
unit in computer systems.
Decision may consist of a combination of smaller
decisions, each one gives either true (binary
value of 1) or false (binary value of 0) situation.
17. 2.3 Binary Logic
2.3.1 Overview
17
First Condition XOR Second Condition
XOR operator can be explained as following; final
result is true if the first and the second condition
are different.
18. 2.3 Binary Logic
2.3.1 Binary Logical Operations
18
The following example illustrates how to apply the
logical operations to the binary numbers.
19. 2.4. Representing Characters
19
Each character we wish to use must be assigned a
unique binary code or number to distinguish it from
all other characters.
There are two coding systems:
1- The ASCII code
2- The Unicode.
20. 20
ASCII (American Standard Code for Information
Interchange).
We have different characters as:
Upper-case (A-Z),
lower-case (a-z),
numerals (0-9),
punctuation (, . ; : etc.) and
control characters (non-printing,e.g. Esc)
2.4. Representing Characters
2.4.1 ASCII Codes (8-bit)
21. 21
The following table shows the ASCII table, showing
the codes used for all different characters.
2.4. Representing Characters
2.4.1 ASCII Codes (8-bit)
22. 22
Note that upper and lower cases of a letter differ
only in bit 5 making case-conversion easy:
To change from lower-to-upper:set bit 5 = 0
To change from upper to lower: set bit 5 = 1
To change case: invert bit 5
2.4. Representing Characters
2.4.1 ASCII Codes (8-bit)
23. 23
The problem with ASCII codes is that a maximum of 256
(8-bit) characters can be represented.
Needed for other languages such as Chinese or Japanese
where there are literally thousands of individual
characters making up the language alphabet.
Unicode allows more than 65,000 characters to be
represented
The first 128 Unicode codes correspond to the standard
ASCII codes.
2.4. Representing Characters
2.4.2 Unicode (16-bit)