Information
Information is best understood as
what it takes to answer a question.
The simplest question has a yes or
no answer. Therefore a bit is the
natural measure of information.
Term first used by John Turkey in
1946.
Concatenation of binary digit.
Usage of bits
Computers are sometimes classified by the
number of bits they can process at one
time. "32 bit processor"
Graphics are also often described by the
number of bits used to represent each dot.
a bit can take the values 0 or 1, thus it can
describe 2 possibilities
The first chips used to process 8 bits at a
time. It become customary to refer to them
as a byte
Many bytes
Larger units are
Kilo byte is 2 power 10 bytes (=1024
bytes)
Mega bytes is 2 power 20 bytes
Giga bytes is 2 power 30 bytes
Tera byte is 2 power 40 bytes
ASCII Code
0 nul
1 soh
2 stx
3 etx
4 eot
5 enq
6 ack
7 bel
8 bs
9 ht
10 nl
11 vt
12 np
13 cr
14 so
15 si
16 dle 32 sp 48 0
64 @
80 P
96 ` 112 p
17 dc1 33 !
49 1
65 A
81 Q
97 a 113 q
18 dc2 34 "
50 2
66 B
82 R
98 b 114 r
19 dc3 35 #
51 3
67 C
83 S
99 c 115 s
20 dc4 36 $
52 4
68 D
84 T 100 d 116 t
21 nak 37 %
53 5
69 E
85 U 101 e 117 u
22 syn 38 &
54 6
70 F
86 V 102 f 118 v
23 etb 39 '
55 7
71 G
87 W 103 g 119 w
24 can 40 (
56 8
72 H
88 X 104 h 120 x
25 em 41 )
57 9
73 I
89 Y 105 i 121 y
26 sub 42 *
58 :
74 J
90 Z 106 j 122 z
27 esc 43 +
59 ;
75 K
91 [ 107 k 123 {
28 fs 44 ,
60 <
76 L
92 \ 108 l 124 |
29 gs 45 61 =
77 M
93 ] 109 m 125 }
30 rs 46 .
62 >
78 N
94 ^ 110 n 126 ~
31 us 47 /
63 ?
79 O
95 _ 111 o 127 del
Binary-Coded Decimal
(BCD)
Four bits per digit
Digit
Bit pattern
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
Example
709310 = ? (in BCD)
7
0111
0000
1001
0011
2.1 Introduction
REVIEW:
A bit is the most basic unit of information in a computer.
It is a state of on or off in a digital circuit.
Sometimes these states are high or low voltage
instead of on or off..
A byte is a group of eight bits.
A byte is the smallest possible addressable (can be found
via its location) unit of computer storage.
A word is a contiguous group of bytes.
Words can be any number of bits (16, 32, 64 bits are
common).
A group of four bits is called a nibble (or nybble).
Bytes, therefore, consist of two nibbles: a high-order
nibble, and a low-order nibble.
12
Numbering Systems
Number System defines a set of values used to represent
quantity.
Base or Radix:The total number of digits available in a
number system .
Decimal Number System:
There are 10 digits i.e 1, 2, 3, 4, 5, 6, 7, 8, 9 available in
decimal number system. It is known as Base 10 system. The
value of a digit in a number depends upon its position in the
number e.g. the number 546 in this system is represented as
(546)10
546 = (4*102) + (8*101) + (6*100)
Binary Number System
The Binary Number System contains 2 unique digits 0 and 1. it
is known as Base 2 system.
15
= 25
16
Fractional Part
1. Multiply the fractional part by the value of
the new base.
2. Record the integer part if it exits, else
record 0.
3. Repeat step 1 with the result of the
previous multiplication and then step 2, until
the fractional part becomes 0. in case of
infinite calculations, generally 6 digits are
taken.
Decimal
Binary
conversion
Convert 75 to Binary
2
2
2
2
2
2
2
75
37
18
9
4
2
1
0
remainder
1
1
0
1
0
0
1
1001011
Check
1001011 =1x20 + 1x21 + 0x22 +
1x23 +
0x24 + 0x25 + 1x26
=1 + 2 + 0 + 8 + 0 + 0 +
64
=75
Representation of integers
An integer is a no. with no fractional
part; it can be positive, negative,or
zero.
Set 0 for positive no.
Set 1 for negative no.
Unsigned integer: containing n bits
can have a value between o and 2n-1
ex. With 8 bits, (0255) can be
represented.
24
25
26
27
28
29
4-bit
Binary
1000
1001
1010
1011
1100
1101
1110
1111
0000
0001
0010
0011
0100
0101
0110
0111
Decimal
-8
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
30
31
00010011,
11101100(add 1)
11101101.
32
Boolean Logic
Operations
Let
x, y, z
be Boolean
Off
On
Low
High
False
True
Example Symbolically
= NOT(x)
x
y
AND z = x AND y
z = x OR y
OR
z = x XOR
XOR y
NOT
xy
x+y
xy
x
0
1
y = x
y = x
z=xy
z=xy
z=x+y
z=x+y
z=xy
z=xy
Text Editor
A text editor is used to edit plain text
files.
They fall into two general categories:
1 Line editor- it requires a specific line
of text before you modify it.
2 Screen oriented editors- modify any
text by moving the cursor to the
desired location.
VI EDITOR
Use vi editor to:
create text files
edit text files
What is vi ?
The visual editor on the Unix.
Before vi the primary editor used on Unix
was the line editor
User was able to see/edit only one line of the
text at a time
Starting vi
Type vi <filename> at the shell
prompt
After pressing enter the command
prompt disappears and you see
tilde(~) characters on all the lines
These tilde characters indicate that
the line is blank
Vi modes
There are three modes in vi
Command mode
Input mode(insert mode)
Execute mode (last line mode)
Moving Around
You can move around only when you
are in the command mode
Arrow keys usually works(but may
not)
The standard keys for moving
cursor are:
h - for left
l - for right
j - for down
k - for up
Moving Around
w - to move one word forward
b - to move one word backward
$ - takes you to the end of line
Moving Around
Control-d scrolls the screen down
(half screen)
Control-u scrolls the screen up (half
screen)
Control-f scrolls the screen forward
(full screen)
Control-b scrolls the screen
backward (full screen).
Entering text
To enter the text in vi you should
first switch to input mode
To switch to input mode there are
several different commands
a - Append mode places the insertion
point after the current character
i - Insert mode places the insertion
point before the current character
Entering text
I - places the insertion point at the
beginning of current line
o - is for open mode and places the
insertion point after the current line
O - places the insertion point before the
current line
R - starts the replace characters, starting
with current cursor position
r - replace 1 character (under the cursor)
with another character
Editing text
x - deletes the current character
d - is the delete command but pressing
only d will not delete anything you need
to press a second key
dw - deletes to end of word
dd - deletes the current line
d0 - deletes to beginning of line