Uploaded by furqanalqowi

1. Computational Mathematics for Information System

advertisement
Computational Mathematics
Written by UUN HARIYANTI, Ph.D.
2023
The Foundation of Logic
Logic and Bit Operations
Computers represent information using bits.
Bit is short for binary digit.
A bit is a symbol with two possible values, namely, 0 and 1 (off or on, false or true, low or high)
Eight bits make a byte, as shown in the picture.
2 bytes (word) would be 16 bits ←→ 2 x 8=16
10 bytes would be 80 bits ←→ 10 x 8=80
We used 1 to represent T (true), 0 to represent F (false).
A variable is called a Boolean variable if its value is either true or false. Consequently, a
Boolean variable can be represented using a bit.
Representations of Integers
In everyday life we use decimal notation to express integers.
2
For example, 965 is used to denote 9 · 10 + 6 · 10 + 5 (it is used base 10, or decimal
expansions)
We can use any integer greater than 1 as the base when expressing integers.
This is stated in Theorem 1.
Theorem 1.
The representation of n given in Theorem 1 is called the base b expansion of n.
Example:
2
(245)8 represents 2 · 8 + 4 · 8 + 5 = 165
In particular, computers usually use:
binary notation (base 2) when carrying out arithmetic, and
octal (base 8) or hexadecimal (base 16) notation when expressing characters, such as letters
or digits.
Binary expansions
Choosing 2 as the base gives binary expansions of integers.
In binary notation each digit is either a 0 or a 1.
Example:
What is the decimal expansion of the integer that has (1 0101 1111)2 as its binary expansion?
Solution:
8
7
6
5
4
3
2
1
0
(1 0101 1111)2 = 1 · 2 + 0 · 2 + 1 · 2 + 0 · 2 + 1 · 2 + 1 · 2 + 1 · 2 + 1 · 2 + 1 · 2 = 351
Note:
2
1
0
(351)10 = 351 because 351 = 3 · 10 + 5 · 10 + 1 · 10
Octal and Hexadecimal expansions
Base 8 expansions are called octal expansions and
base 16 expansions are hexadecimal expansions.
Sixteen different digits are required for hexadecimal expansions.
Usually, the hexadecimal digits used are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F,
where the letters A through F represent the digits corresponding to the numbers 10 through 15
(in decimal notation).
Example:
What is the decimal expansion of the number with hexadecimal expansion (2𝐴𝐸0𝐵)16?
Solution:
4
3
2
1
0
(2𝐴𝐸0𝐵)16 = 2 · 16 + 10 · 16 + 14 · 16 + 0 · 16 + 11 · 16 = 175627
Each hexadecimal digit can be represented using four bits.
For instance,
(1110 0101)2 = (𝐸5)16 because (1110)2 = (𝐸)16 and (0101)2 = (5)16 .
Bytes (bit strings of length eight) can be represented by two hexadecimal digits.
Base Conversion.
Example:
Find the binary expansion of (241)10.
Solution:
241 = 2 · 120 + 1
120 = 2 · 60 + 0
60 = 2 · 30 + 0
30 = 2 · 15 + 0
15 = 2 · 7 + 1
7 = 2·3+1
3=2·1+1
1 = 2 · 0 + 1 (stop)
Thus, (241)10 = (1111 0001)2
Example:
Find the hexadecimal expansion of (691)10.
Solution:
691 = 16 · 43 + 3
43 = 16 · 2 + 11
2 = 16 · 0 + 2
(stop)
(11 = B)
Thus, (691)10 = (2𝐵3)16
Download