Lesson 1: Transforming Numerical Systems
Binary Numbers
Base system uses base B, and includes numbers 0, 1, 2, ... , B‑1
For example in decimal system B=10, and numbers included are 0, 1, 2, ..., 8 & 9.
If the base B=2, then the system is binary, and its numbers are 0 & 1.
From English term BInary digiT, comes the name for lowest amount of information BIT.
Example:
5710= 5 * 101 + 7 * 100 = 1*25+ 1*24 + 1*23 + 0*22 + 0*21 + 1*20= 1 1 1 0 0 1 2
Number 57 in decimal is shown by two numbers, while in binaries six figures are necessary to show data. Binaries compared to other numbering systems, logically use most amount of elements (data) to give us information. Number of BITS used to write down a number is limited due to technical reasons.
Machines used to process and save binary information, are usually constructed form electronic elements with 2 stable states (bistables), which are efficient and cheap to produce.
Switching from decimal to binary numbers:
Binary number is made by leftovers we get from dividing (reading upwards)
57 : 2 = 28 1 1 1 0 01
1
28 : 2 = 14
0
14 : 2 = 7
0
7 : 2 = 3
1
3 : 2 = 1
1
1 : 2 = 0
1
Negative Binary Numbers
Operation 7 – 5 , using computer with 4 bit length registry will be processed like
7 + (-5). Binary result of -5 can be achieved:
Positive Number 0 1 0 1
Complement till base -1 1 1 1 1
( one komplement) - 0 1 0 1
1 0 1 0
Complement till base 1 0 1 0
(dual complement) + 0 0 0 1
1 0 1 1
Proof that the result is - 5 Excluding operation 7 - 5
1 0 1 1 (-5)
+ 0 1 0 1 (+5)
---------------
0 0 0 0
extra 1
0 1 1 1 ( 7)
+ 1 0 1 1 (-5)
---------------
0 0 1 0
extra 1
If we have n=3 bit length registry, (first bit reserved for telling us if its –/+), next numbers can be shown:
Decades Binaries
0 000
1 001
2 010
3 011
-4 100
-3 101
-2 110
-1 111
0 000
1 001
2 010
3 011
-4 100
-3 101
-2 110
-1 111
For n = 3 we get interval [‑22, 22‑ 1], in general [‑2n‑1, 2n‑1‑ 1].
Forn = 8 we get interval [‑27, 27‑1], exact range [‑128, 127].
Octal System
Base of the system is B=8 and numbers used are 0, 1, 2, 3, 4, 5, 6, 7.
This system is used for shorter description of binaries when its needed.
Example:
36‑bit number 001 110 000 101 111 001 010 011 111 000 100 001
Octal equivalent 16 0 5 7 1 23 7 0 4 1
Hexadecimal System
Base of the system is B=16 and numbers used are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. This system is used for shorter description of binaries when it’s needed.
Example:
16‑bit number 0111 1011 0011 1110
Hexadecimal equivalent. 7B 3 E
Rational numbers
Rational numbers have binary "spot” which is similar to decimal spot used by decimal numbers.
Example:conversion of rational number
5.75 10 = 5 * 100 + 7 * 10‑1 + 5 * 10‑2 =
= 1*22 + 0*21 + 1*20 + 1*2‑1 + 1*2‑2 = 1 0 1 . 1 1 2
Conversion of decimal number to binary number
1.25 = 1+ .25.25 * 2 1 . 0 1
0.50
.5 * 2
1.0
Example:conversion of this decimal number - when conversed, it has infinite number of fractions in its binary state
13.3= 13 + 0.3.3 * 2 1 1 0 1 . 0 1 0 0 1 1 0 0 1 ...
0.6
.6 * 2
1.2
.2 * 2
0.4
.4 * 2
0.8
.8 * 2
1.6
.6 * 2
1.2
....
Notice that finite decimal number is shown as infinite periodic binary number.
Binary Number is mounted with exponent of Base 2, in a way that a binary dot is moved left or right, depending if exponent is positive or negative
Example: 1 . 1 1 * 22 = 1 1 1
No comments:
Post a Comment