Chapter 4 Intro
Chapter 4 Intro
2 44 Remainder
2 11 0
2 5 1
2 2 1
0
2 1
1
1
MSB (Most Significant Bit)
Taking the remainder in reverse order we have 101100. Thus the binary equivalent of
(44)10 is (101100)2
Binary to Decimal
Each digit of the binary number is multiplied by its weighted
position, and each of the weighted values is added together to get
the decimal number.
In general to convert a number X consists of digits X1 X2 X3
…Xn in base m to decimal; simply expand the number with
base m. That is
(X1X2X3…Xn) m =X1*mn-1+X2*mn-2 +X3*mn-3+...+ Xi*mn-i+… Xn-
1m +Xn*m
1 0
=Y10
Character Zone
digits
A 11 0001
Q 10 1000
8 00 1000
9 00
1001
ASCII-7
ASCII stands for American Standard Code for Information
Interchange.
ASCII-7 used widely before the introduction of ASCII-8 (the
Extended ASCII).
It uses 7 bits to represent a character. With the seven bits,
27( or 128) different characters can be coded (0000000-
1111111).
It has 3 zone and 4 digit bits positions
Coding examples:
a 0110 0001
b 0110 0010
A 0100 0001
B 0100 0010
? 0011 1111
+ 0010 1011
1 0011 0001
Unicode
has started to replace ASCII and other coding
methods at all levels.
Unicode provides a unique number for every
character, no matter what the platform, no matter
what the program, no matter what the language.
It enables users to handle not only practically any
script and language used on this planet; it also
supports a comprehensive set of mathematical
and technical symbols to simplify scientific
information exchange.
Unicode was originally designed to be a 16-bit
code, but it was extended so that currently code
positions are expressed as integers in the
hexadecimal range 0..10FFFF (decimal
0..1 114 111).
4.4Representation of Negative
Numbers and Arithmetic
There are different ways of representing negative
numbers in a computer.
1. Sign- magnitude representation.
In signed binary representation, the left-most bit is used to
indicate the sign of the number. Traditionally, 0 is used
to denote a positive number and 1 is used to denote a
negative number. But the magnitude part will be the same
for the negative and positive values.
In general for n-bit sign magnitude representation the
range of values that can be represented are –(2 n-1-1 ) to
(2 n-1-1).
Example 2: Represent –24 using 8-bits sign
magnitude representation
24=00011000
-24 = 10011000
2. One’s Complement
In one’s complement representation, all positive integers are
represented in their correct binary format.
Each 0 is transformed into a 1 and each 1 into a 0.
Example: +2 is 00000010
-2 is 11111101
Note that in this representation positive numbers start with a 0
on the left, and negative numbers start with a 1 on the left most
bit.
Example 1: add –3 and 3 with word size 4
3 = 0011
-3 = 1100
sum = 1111 (=0)
Ex2. Add -4 and +6
- 4 is 11111011
+ 6 is 00000110
The sum is (1) 00000001
Where 1 indicates a carry. The correct result should be 2 or
00000010.
3. Two’s Complement Representation
In two’s complement representation, positive
numbers are represented, as usual, in singed
binary, just like in one’s complement.
The difference lies in the representation of
negative numbers.
A negative number represented in two’s
complement is obtained by first computing the
one’s complement and then add one.
Example: +3 is represented in signed binary as
00000011
Its one’s complement representation is
11111100.
The two’s complement is obtained by adding
one.