Number System
Number System
Number System
Outline
Number System
Binary Numbers
MSB
LSB
1111011
A doubleword is 2 words
A doubleword is 4 bytes
A quadword is 2 doublewords
A kilobyte is
20
2
A megabyte is
bytes, that is 1,048,576 bytes
A gigabyte is 2
30
Unsigned/Signed Numbers
One byte (eight bits) can be used to represent the decimal number range
0 to 255 (unsigned)
Find 8 bit signed binary numbers for -35(D). Use direct method and 2s complement
Golden Question:
So how can you tell the difference between:
-123(D)= 10000101(B)
and
133(D) = 10000101(B)
You cant unless you know whether youre using signed or unsigned arithmetic:
Base of 16
Numerical symbols, 0 9 ; A F for ten fifteen
Example 70A(H) or
70A16
7B
7161 + 11160 = 12310
=
=
=
=
=
=
=
61
30
15
7
3
1
0
remainder 1
remainder 1
remainder 0
remainder 1
remainder 1
remainder 1
remainder 1
123
16
7 16
= 7 remainder 11 (or B)
= 0 remainder 7
0111 1011
7B
E.g.
Unicode http://www.unicode.org
ASCII Characters
ASCII stands for American Standard Code for Information Interchange (1960)
ASCII Tables :
A: 41(H)
a: 61(H)
BCD
Definition BCD represents each of the digits of an unsigned decimal as the 4-bit
binary equivalents.
Unpacked BCD In unpacked BCD, the lower 4 bits of the number represent the
BCD number and the rest of the bits are 0. Example: 0000 1001 and 0000 0101
are unpacked BCD for 9 and 5, respectively. In case of unpacked BCD it takes 1
byte of memory location or a register of 8 bits to contain it.
Packed BCD In packed BCD, a single byte has two BCD numbers in it, one in the
lower 4 bits and one in the upper 4 bits. For example, 0101 1001is packed BCD
for 59. It takes only 1 byte of memory to store the packed BCD operands. This is
one reason to use the packed BCD since it is twice as efficient in storing data.
Why use binary coded decimal? Because people think in decimal
Exercise :
194(d) -> unpack and pack ? 238(d) to unpack and pack ?
0000 0011
0000 0011
0000 0011
Ex:
b) Exponent
represent both positive and negative exponents.
Base 2
a bias is added to the actual exponent in order to get the stored exponent.
For IEEE single-precision floats, this value is 127 (7F).
- A stored value of 200 indicates an exponent of (200-127), or 73
For double precision, the exponent field is 11 bits, and has a bias of 1023 (3FF).
c) Mantissa
The mantissa, also known as the significand, represents the precision bits of the number
http://steve.hollasch.net/cgindex/coding/ieeefloat.html
The floating-point numbers in (a) single-precision using a bias of 7FH and (b)
double-precision using a bias of 3FFH.
.75 x 2 =1.5
.5 x 2 = 1
.75 -> .11
0100 0001 0001 1100 0000 0000 0000 0000 = 411C0000 (h)
Example 2
Convert -12.62510 in single precision IEEE-754 format
Step #1: Convert to target base. -12.62510 = -1100.1012
Step #2: Normalize. -1100.1012 = -1.100101 x 23
Step #3: Set bit 31 for sign : 1(negative)
Step #3: Find the exponent : 3 + 127(d) = 130(d) = 82(h) = 1000 0010 (b)
Step #4: Put together 1 1000 0010 1001 0100 0000 0000 0000 000
1100 0001 0100 1010 0000 0000 0000 0000 (b) = ?
Example 4
0
10000010
11000000000000000000000
+1.75 23 = 14.0
Example 5
Given IEEE SP 41C8 000016 , find the real number
1. 0100 0001 1100 1000 0000 0000 0000 00002
2. Sign bit: 0
Exponent: 1000 00112 = 8316 = 131 (d)
Decoded exponent: 131 - 127 = 4 (d)
3. Significand: 100 1000 0000 0000 0000 00002
Decoded significant: 1 + 0.5 + 0.0625 = 1.5625 (d)
4. 1.5625 24 = 25 (d)
Exercise
Following is IEEE SP number, find the number
11000011100101100000000000000000
We have seen how numbers are represented in micro-p. How are they stored ?
ENDIAN : ordering of individually addressable sub-components within the representation of a
larger data item as stored in external memory
"Little Endian"
low-order byte of the number is stored in memory at the lowest address, and the highorder byte at the highest address. (The little end comes first.)
For example, a 4 byte Long Int : Byte3 Byte2 Byte1 Byte0
will be arranged in memory as follows
Base Address+0 Byte0
Base Address+1 Byte1
Base Address+2 Byte2
Base Address+3 Byte3
Big Endian"
means that the high-order byte of the number is stored in memory at the lowest address,
and the low-order byte at the highest address. (The big end comes first.)
Example 6