Number Systems - George Washington University
Number Systems
Purposes:
1. To understand how does a digital computer work. Binary digital computers only work with 1’s and 0’s, or high and low voltage, or true and false.
2. To convert among different number systems. We use decimal numbers everyday. Computers understand only binary numbers, which are lengthy and inconvenient to human beings. Octal and Hexadecimal numbers are introduced to make both happy: they are easier to be converted to binary numbers and also easier for us to handle.
Classification:
[pic]
Unsigned Numbers
Radices and Characters:
• Binary: 0, 1
• Decimal: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
• Octal: 0, 1, 2, 3, 4, 5, 6, 7
• Hexadecimal: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
Structure of a number:
[pic]
Note: If no fractional part, the radix point can be omitted!
Positional Notation:
[pic],
where [pic], and [pic] is the radix.
Practice Problem 1:
Given the positional notations of the following numbers: (1101.1)2, (724)8, and (BCD)16.
Converting Numbers Between Bases:
• Conversion to Decimal: write the number using the positional notation and then perform decimal arithmetic to compute the result, which is the decimal number.
To speedup, using HORNER’s RULE.
Example: Convert (6734)8 into decimal.
Example: Convert (A6B3)16 into decimal using Horner’s rule.
Example: Convert (1101)2 into decimal.
• Conversion from Decimal:
Integer part: Divide the decimal number by the base to which we want to convert and cast out the reminders.
Fractional part: Multiply the decimal number by the base to which we want to convert and cast out the integer part.
Rationale: based on the positional notation.
Example: Convert (29)10 into Binary, to Octal, and to Hexadecimal.
Example: Convert (217)10 into a hexadecimal, an octal and a binary number.
Example: Convert (0.57)10 to binary, octal and hexadecimal
Example: Convert (0.6328125)10 to binary, octal and hexadecimal.
Note: When converting to binary, the process may never stop for some irrational decimal numbers. In this case, we need to (1) figure out the precision of the decimal number; (2) determine when to stop based on the precision. Eg. (0.57)10
=0.10010001 since the precision of (0.57)10 is 1/100 and we need at least 7 bits for this precision.
• Binary to/from Octal and Hexadecimal: Starting at the binary point, cast off three (four) bits at a time and convert each group to its octal (hexadecimal) equivalent. Padding 0’s to the left for the integer part and to the right for the fractional part when necessary.
Example: Convert (10110111)2 to an octal and a hexadecimal number.
Example: Convert (0.10110111)2 to an octal and a hexadecimal number
Question: How to convert octal to/from hexadecimal?
Practice Problem 2: Fill in the missing entries
|Decimal |Binary |Octal |Hexadecimal |
|136 | | | |
| |10101100 | | |
| | |357 | |
| | | |BC |
|23.157 | | | |
| |0.1010110011 | | |
| | |0.532 | |
| | | |AF.2345 |
|0 |00000000 |000 |00 |
Signed Numbers
Signed-Magnitude: 0 for positive, 1 for negative, followed by the magnitude in different radix. A signed-magnitude number can be represented as
[pic]
where [pic] is the sign bit and [pic] is the ith character in the number.
Note: Generally we use floating-point numbers to represent a mixed radix-point number. Thus we focus on signed integers now.
Example: Given the signed-magnitude notations of (+9)10 and (-9)10 in binary, octal, decimal, and hexadecimal form.
(+9)10 = ( ) 2sm and (-9)10 = ( )2sm
(+9)10 = ( ) 8sm and (-9)10 = ( )8sm
(+9)10 = ( ) 10sm and (-9)10 = ( )10sm
(+9)10 = ( ) 15sm and (-9)10 = ( )15sm
Diminished Radix-Complement (for integer): 0 for positive, followed by the magnitude in different radix; (r-1) for negative, followed by the complement of the magnitude of the number:
[pic]
where r is the radix and N is the number.
The complement is computed by taking each character in the number and subtracting the character from (r-1).
Example (Nine’s Complement):
(+9574) 10 = ( ) 9C and (-9574)10 = ( )9C
Example (One’s Complement): (+9)10 = ( )1C and (-9)10 = ( )1C What is the result of the sum of (+9)10 and (-9)10 in one’s complement? – Negative zero
Example (15’s Complement):
(+30) 10 = ( ) 15C and (-30)10 = ( )15C
Radix-Complement (for integer): For a negative number, adding one to its Diminished-Complement; For positive numbers, radix-complement = diminished radix-complement.
Example (Ten’s Complement):
(+9574) 10 = ( ) 10C and (-9574)10 = ( )10C
Example (Two’s Complement): (+8)10 = ( )2C and (-8)10 = ( )2C What is the result of the sum of (+8)10 and (-8)10 in one’s complement? – unique zero
Example (16’s Complement):
(+30) 10 = ( ) 16C and (-30)10 = ( )16C
Fill in the entries of the following table:
|Decimal |Signed-magnitude |1’s complement |2’s complement |notes |
|0 | | | | |
|1 | | | | |
|2 | | | | |
|3 | | | | |
|4 | | | | |
|5 | | | | |
|6 | | | | |
|7 | | | | |
|-7 | | | | |
|-6 | | | | |
|-5 | | | | |
|-4 | | | | |
|-3 | | | | |
|-2 | | | | |
|-1 | | | | |
| | | | | |
Remarks:
1. The sign bit is part of the number in one’s and two’s complement notation and is included in any computations.
2. In two’s complement , the number 0 is expressed as all zeros, the number -1 is expressed as all 1’s.
3. Digital computers use 2’s complement for arithmetic operation.
Question: What is the largest positive/negative signed 32-bit numbers in two’s complement?
Floating-Point Numbers
Remark:
1. We only consider binary numbers.
2. Floating-point expands the range of numbers representable in a digital computer and improves precision.
3. It is the binary scientific notation:
Examples: [pic] and [pic]
sign: +
Mantissa – one non-zero digit followed by the radix point: 5.42713
Base: 10
Exponent – signed integers: -23
IEEE 754 Single-Precision Floating-Point Standard:
IEEE 754 Double-Precision Floating-Point Standard:
Remarks:
1. The hidden 1 must be included in the significand to get the mantissa.
2. Use biased exponent to facilitate sorting. For single-precision fp, the bias is (127)10, for double-precision, it is (1023)10.
The value of a floating-point number is:
Example: Show the IEEE 754 binary representation for the floating point number (-0.75)10 in single-precision for a 32-bit computer.
Practice Problem 3: What decimal number does the following floating-point number represent?
1100 0001 1101 0000 0000 0000 0000 0000
Special representations in IEEE 754 Standard
|Exponent |Significand |Exponent |Significand |Object |
|0 |0 |0 |0 |0 |
|0 |Non-zero |0 |Non-zero |Denomalized numbers |
|1-254 |Anything |1-2046 |anything |Normalized FP numbers |
|255 |0 |2047 |0 |infinity |
|255 |Non-zero |2047 |Non-zero |NaN |
Overflow: The exponent of the number is too large to be put in the exponent field.
Underflow: The exponent is too small (or the absolute value is too large) to be put in the exponent field.
Double-Precision FP increases both range and precision because there are more number of bits in the exponent and the significand fields.
Question: What are the smallest normalized numbers (positive and negative) that a single-precision FP can represent?
Practice Problem: Fill in the entries in the following table.
|Decimal Number |Single Precision FP |
|0 | |
|10.5 | |
|-2/3 | |
|-0.1 | |
-----------------------
Numbers
Unsigned Numbers
Signed Integers
Signed-Magnitude
Diminished
Radix-Complement
Radix-Complement
Floating-Point Numbers
Single-Precision
Double-Precision
dn-1 dn-2 … d2 d1 d0 . d_1 d_2 … d_m
Radix point
Fractional Part
Integer Part
Single precisoin
Double precisoin
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- who was george washington s vice president
- george mason university mason core
- george mason university graduate school
- george mason university information technology
- george mason university library catalog
- george mason university course catalog
- george mason university course schedule
- george washington university biology ranking
- george mason university admissions requirements
- george mason university reputation
- george mason university sat requirements
- george mason university admissions gpa