Uploaded on

The following presentation is a part of the level 4 module -- Digital Logic and Signal Principles. This resources is a part of the 2009/2010 Engineering (foundation degree, BEng and HN) courses from …

The following presentation is a part of the level 4 module -- Digital Logic and Signal Principles. This resources is a part of the 2009/2010 Engineering (foundation degree, BEng and HN) courses from University of Wales Newport (course codes H101, H691, H620, HH37 and 001H). This resource is a part of the core modules for the full time 1st year undergraduate programme.
The BEng & Foundation Degrees and HNC/D in Engineering are designed to meet the needs of employers by placing the emphasis on the theoretical, practical and vocational aspects of engineering within the workplace and beyond. Engineering is becoming more high profile, and therefore more in demand as a skill set, in today’s high-tech world. This course has been designed to provide you with knowledge, skills and practical experience encountered in everyday engineering environments.

More in: Education
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
1,279
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
40
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Number Bases Digital Logic and Software Applications © University of Wales Newport 2009 This work is licensed under a Creative Commons Attribution 2.0 License .
  • 2.
    • The following presentation is a part of the level 4 module -- Digital Logic and Signal Principles. This resources is a part of the 2009/2010 Engineering (foundation degree, BEng and HN) courses from University of Wales Newport (course codes H101, H691, H620, HH37 and 001H). This resource is a part of the core modules for the full time 1 st year undergraduate programme.
    • The BEng & Foundation Degrees and HNC/D in Engineering are designed to meet the needs of employers by placing the emphasis on the theoretical, practical and vocational aspects of engineering within the workplace and beyond. Engineering is becoming more high profile, and therefore more in demand as a skill set, in today’s high-tech world. This course has been designed to provide you with knowledge, skills and practical experience encountered in everyday engineering environments.
    • Contents
    • Introduction
    • Binary
    • Here is a listing of the first few numbers:
    • Base 4
    • Base Seven
    • Hexadecimal
    • Number Systems (binary)
    • How do we represent negative numbers?
    • Floating Point Numbers
    • Credits
    • In addition to the resource below, there are supporting documents which should be used in combination with this resource. Please see:
    • Holdsworth B, Digital Logic Design, Newnes 2002
    • Crisp J, Introduction to Digital Systems, Newnes 2001
    Stabilised Power Supplies
  • 3.
    • Those of us who are old enough remember when the base for many counting systems was not always 10. Examples are:
    • Distance 12 inches in 1 foot
    • 3 feet in one yard
    • 22 yaers in 1 chain etc
    • Weight 16 ounces in 1 pound
    • 14 pounds in one stone
    • 8 stones in 1 hundredweight
    • Money 12 pennies in one shilling
    • 20 shillings in one pound.
    • Not to mention time and angles.
    Number Bases
  • 4.
    • Some people may question the requirement for the knowledge to convert between bases but with the development of computers and digital systems the system may not represent numbers or value using the standard decimal system.
    • The Decimal System.
    • These days the normal system of counting is the decimal system which has as its base 10 – this means that we have 10 unique representation for the numbers between 0 and 9. Above 9 we use a combination of digits and their position to represent the rest of the numbers e.g. 10 is 1 then 0, the 1 being to the left of the 0 meaning that it is scaled by 10.
    Number Bases
  • 5.
    • Each time a digit is moved to the left it is scaled by another 10
    • 2 3 4
    • 2x10x10 3x10 4x1
    • 2x10 2 3x10 1 4x10 0
    • The further to the left the larger the multiplier. On the right of the units digit we have a decimal point which indicates the starting point for the system of counting. If we have digits to the right of this the same process applies but the powers of the base become negative:
    • 4 7 . 5 6
    • 4x10 1 7x10 0 . 5x10 -1 6x10 -2
    • 4x10 7x1 . 5x0.1 6x0.01
    Number Bases
  • 6.
    • The reason that we use ten is based on the fact that we have ten digits and from our childhood we have used our fingers to keep track of occurrences we are monitoring.
    • It is interesting to note what our system of counting would have been if we has 8 digits (four on each hand)
  • 7. Binary base 2
    • Binary has as its base 2 – this means that we have 2 unique representation for the numbers between 0 and 1 – these being 0 and 1. Above 1 we use a combination of digits and their position to represent the rest of the numbers e.g. 2 is 1 then 0, the 1 being to the left of the 0 meaning that it is scaled by 2.
    • Each time a digit is moved to the left it is scaled by another 2
    • 1 0 1
    • 1x2x2 0x2 1x1
    • 2x2 2 0x2 1 1x2 0
  • 8. Binary base 2
    • The further to the left the larger the multiplier. On the right of the units digit we have a binary point which indicates the starting point for the system of counting. If we have digits to the right of this the same process applies but the powers of the base become negative:
    • 1 0 . 0 1
    • 1x2 1 0x2 0 . 0x2 -1 1x2 -2
    • 1x2 0x1 . 0x0.5 1x0.25
  • 9. Here is a listing of the first few numbers: Number Bases decimal (base 10) binary (base 2) 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 0 1 10 11 100 101 110 111 1000 1001 1010 1011 1100 1101 1110 1111 10000 0 ones 1 one 1 two and zero ones 1 two and 1 one 1 four, 0 twos, and 0 ones 1 four, 0 twos, and 1 one 1 four, 1 two, and 0 ones 1 four, 1 two, and 1 one 1 eight, 0 fours, 0 twos, and 0 ones 1 eight, 0 fours, 0 twos, and 1 one 1 eight, 0 fours, 1 two, and 0 ones 1 eight, 0 fours, 1 two, and 1 one 1 eight, 1 four, 0 twos, and 0 ones 1 eight, 1 four, 0 twos, and 1 one 1 eight, 1 four, 1 two, and 0 ones 1 eight, 1 four, 1 two, and 1 one 1 sixteen, 0 eights, 0 fours, 0 twos, and 0 ones
  • 10.
    • We can convert between binary and decimal using the following technique (integers):
    • Start with the left most (most significant) digit
    • Multiply by the base
    • Add the next digit to the right.
    • If this was the last digit stop if not repeat steps 2 to 4.
    • Convert 10110110 2 to the corresponding base-ten number.
    • 1 0 1 1 0 1 1 0
    • 1 2 5 11 22 45 91 182
    • 2 4 10 22 44 90 182
    Number Bases Multiply by the base Add the next digit Result
  • 11.
    • We can convert between decimal and binary using the following technique (integers):
    • Write the decimal number on the right of the page.
    • Divide by the base
    • Write down the whole part of result to the left and the remainder above the new number.
    • If the whole part was zero stop if not repeat steps 2 to 4.
    • Convert 182 to the corresponding binary number.
    • 1 0 1 1 0 1 1 0
    • 0 1 2 5 11 22 45 91 182
    Number Bases Divide by the base Note the remainder Result
  • 12. Quaternary Base 4 Number Bases Quaternary has as its base 4 – this means that we have 4 unique representation for the numbers between 0 and 3 – these being 0, 1, 2 and 3. Above 3 we use a combination of digits and their position to represent the rest of the numbers e.g. 4 is 1 then 0, the 1 being to the left of the 0 meaning that it is scaled by 4. Each time a digit is moved to the left it is scaled by another 4 3 2 1 3x4x4 2x4 1x1 3x4 2 2x4 1 1x4 0
  • 13.
    • Rules for conversion are the same as binary but this time the base is 4.
    • Convert 276 10 to the corresponding base-four number.
    • Convert 1235 10 to the corresponding base-four number.
    • Convert 20213 4 to the corresponding decimal number.
    Number Bases
  • 14. Base Seven
    • I have never seen this base used but it could exist. See previous notes but with the base being seven and the seven digits being 0, 1, 2, 3, 4, 5 and 6
    • Convert 537 10 to the corresponding base-seven number.
    • Convert 14946 10 to the corresponding base-seven number.
    • Convert 13634 7 to the corresponding decimal number.
    Number Bases
  • 15. Octal Base 8
    • This was used in the first computers and had eight as its base The digits in octal math are 0, 1, 2, 3, 4, 5, 6, and 7.  The value "eight" is written as "1 eight and 0 ones", or 10 8 .
    • Convert 357 10 to the corresponding base-eight number.
    • Convert 545 8 to the corresponding decimal number.
    Number Bases
  • 16. Hexadecimal Base 16
    • Hexadecimal has as its base 16 – this means that we have 16 unique representation for the numbers between 0 and 15. This causes some problems as we only have 10 normal decimal digits. To suplement this we have the letters a to F. The hexadecimal digits are therefore 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E and F. Above 15 we use a combination of digits and their position to represent the rest of the numbers e.g. 16 is 1 then 0, the 1 being to the left of the 0 meaning that it is scaled by 16.
    Number Bases
  • 17.
    • Each time a digit is moved to the left it is scaled by another 16
    • D 7 E
    • 13x16x16 7x16 14x1
    • 13x16 2 7x16 1 14x16 0
    • But the conversions work in the usual manner.
    • Convert 357 10 to the corresponding hexadecimal number.
    • Convert 165 16 to the corresponding decimal number.
    • Convert 63933 10 to the corresponding hexadecimal number.
    • Convert F9BD 16 to decimal notation.
    Number Bases
  • 18.
    • Hexadecimal to Binary
    • Simply replace each hexadecimal digit by its 4-bit binary equivalent and concatenate the number. Remove any leading zeros.
    • Convert F9BD 16 to binary notation.
    • Binary to Hexadecimal
    • Group the binary digits into fours from the right. Add leading zeros if the number of bits is not a multiple of four. Each four-bit group is then converted into a hexadecimal digit.
    • Convert 1011010101 2 to the corresponding hexadecimal number.
    Number Bases
  • 19. Number Systems (binary)
    • Unsigned Binary:
    • Numbers stored in 8 bits can hold numbers in the range:
    • 00000000 which represents 0 and
    • 11111111 which represents 255
    • with 16 bits the range increases to:
    • 0000000000000000 which represents 0 and
    • 1111111111111111 which represents 65535
    • above this is 32 bits where
    • all 0’s once again represents 0 while:
    • 11111111111111111111111111111111
    • is the number 4,294,967,295 or 2 32 - 1
    Number Bases
  • 20.
    • For most integers we would rarely require more than 32-bits to represent and integer and often we can get away with 8-bits or 16-bits.
    • The unsigned numbers are assumed to be positive but as the name implies, sign is meaningless.
    • If a variable can take both positive and negative values then we must use signed numbers. To do this something must replace the - sign and the + sign. This is done using the most significant bit of the number.
    Number Bases
  • 21.
    • For 8-bit numbers:
    • D7 D6 D5 D4 D3 D2 D1 D0
    • D7 is used to indicate the sign. 0 represents positive, 1 negative.
    • i.e. 01011101 is a positive number whilst
    • 11001010 is a negative number
    • We now have only 7-bits to represent the number and therefore the largest positive number which can be represented is +127 or
    • 01111111
    Number Bases
  • 22. How do we represent negative numbers?
    • We could use a sign and a normal binary number, i.e.
    • -9 = 10001001
    • - 9
    • This has two limitations.
    • 1) We have two representation for 0 +0 and -0
    • 00000000 and 1 0000000
    • his limits the representable numbers to -127 to +127
    • 2) Arithmetic does not work.
    • Consider the problem +9 + -9
    • 00001001
    • + 10001001
    • 10010010 = -18
    Number Bases
  • 23.
    • We therefore use a method called 2’s complement
    • The number to be negated (made negative) is subtracted from a row of 1’s and 1 is added. therefore -9 would be represented as:
    • 11111111
    • - 00001001
    • 11110110
    • + 1
    • 11110111  -9
    • Now 9 +-9 gives us
    • 00001001
    • + 11110111
    • ignore - 1) 00000000
    Number Bases
  • 24.
    • The range using this method gives us one more negative number; therefore we have a range -128 to +127
    • One method of converting signed numbers is to think as the left digit (MSB the most significant bit) as representing a negative quantity
    • i.e. 1 1 1 1 0 1 1 1
    • -128 +64 +32 +16 +8 +4 +2 +1
    • which gives us -128 +119 = -9
    • for large numbers of bits in the word:
    • 16-bits can represent numbers in the range
    • -32768 to +32767
    • and 32-bits, numbers in the range
    • -2,147,483.648 to +2,147,483.647
    Number Bases
  • 25.
    • Note that a digital system will see a string of 0’s and 1’s and it will interpret them accordingly. The system does not know whether they are signed or unsigned.
    • The number 10110110 may mean 182 or -74 depending upon the interpretation we put on it. This leads to difficulty because
    • 10110110 would be greater than 01111111 in unsigned but
    • 10110110 would be less than 01111111 in signed.
    • So comparison instructions must imply whether signed or unsigned is being implemented.
    Number Bases
  • 26. Floating Point Numbers
    • In addition to signed and unsigned integers, programming languages include numbers to represent numbers with fractions, which are called reals in mathematics.
    • Here are some examples:
    • 3.1415926539 ...
    • 2.718121818
    • 0.000000001 or 1.0 x 10 -9
    • 3,155,760,000 or 3.15576 x 10 9
    • Notice in the last case the number did not represent a fraction but it was bigger than we can represent with a signed integer.
    Number Bases
  • 27.
    • The alternative notation for the last two is called scientific and involves having one digit to the left of the decimal point. A number that has no leading zeroes and is in scientific notion is called a normalized number.
    • Therefore 0.1 x 10 -8 is the same as the third number but is not normalized.
    • Just as we can show decimal numbers in scientific notation we can also show binary in scientific notation.
    • 1.0 x 2 2 represents ................................
    • The binary base replaces the decimal base so that we can adjust the exponent by 1 to keep the binary number in normalized form.
    Number Bases
  • 28.
    • Computer arithmetic that supports such numbers is called floating point, because it represents numbers in which the decimal point is not fixed, as it is for integers. Just as in scientific notation, numbers are represented by a single digit to the left of the decimal point. In binary the form is:
    • +1.xxxxxxxxx x 2 yyyy
    Sign Significant Exponent Number Bases
  • 29.
    • A standard scientific notation for reals in normalized form offers three advantages.
    • 1) It simplifies exchange of data that includes floating point numbers;
    • 2) It simplifies the floating point arithmetic algorithms to know that the numbers will always be in the same form.
    • 3) It increases the accuracy of the numbers that can be stored in a word, since the unnecessary leading zeros are replaced by real numbers to the right of the decimal point.
    Number Bases
  • 30.
    • Typical make up of a floating point number.
    • The number is stored in 32 bits or 4 bytes.
    • It consists of 1 sign bit, an 8-bit exponent field and a 23-bit significant, as below
    In general floating point numbers are of the form: (-1) S x F x 2 E F involves the value of the significant field and E involves the value of the exponent field. The exact relationship will be seen later. Number Bases 27 26 24 25 31 30 28 29 19 18 16 17 23 22 20 21 11 10 8 9 15 14 12 13 3 2 0 1 7 6 4 5 S Exponent Significant 1 bit 8 bits 23 bits
  • 31.
    • The designer of arithmetic must find a compromise between the size of the significant and the size of the exponent, because a fixed word size means you must take a bit from one to add it to the other. The trade-off is between accuracy and range. Increasing the size of the significant enhances the accuracy of the number, but increasing the size of the exponent increases the range of the numbers that can be represented. A guideline of any designer will be good design demands compromise.
    • The above chosen sizes of significant and exponent allow us to represent numbers in the range of 2.0 x 10 38 to as small as 2.0 x 10 -38
    Number Bases
  • 32.
    • Alas, it is still possible for numbers to be too large and this would cause an overflow. Unlike integer arithmetic it is also possible for numbers to be too small leading to an underflow. Both of these cases would imply that the exponent was too large, either positive or negative.
    • To reduce the chances of overflow and underflow, programming languages offer what is referred to as double precision numbers and these use two 32-bit words which is the equivalent of 8 bytes. The form is shown below.
    27 26 24 25 31 30 28 29 19 18 16 17 23 22 20- 21 11 10 8 9 15 14 12 13 3 2 0 1 7 6 4 5 S Exponent Significant 1 bit 11 bits 20 bits Significant (cont’d) 32 bits
  • 33.
    • S is still the sign bit, the exponent E is now 11-bits and the significant is 52-bits in length.
    • This form of representing floating point numbers allows numbers in the range 2.0 x 10 308 down to 2.0 x 10 -308
    • These forms are part of the IEEE 754 floating point standard , found in virtually every computer invented since 1980. The standard has improved the quality of floating-point programs and the quality of arithmetic.
    • To pack even more bits into the significant, IEEE 754 makes the leading 1 bit of the normalized binary numbers implicit. Hence the significant for single precision is actually 24-bits and for double precision 53-bits.
    Number Bases
  • 34.
    • One problem is 0 in floating point as this does not have a normalized 1. In this case it is given the reserved exponent of 0.
    • The rest of the numbers use the original:
    • (-1)S x (1 + significant) x 2 E
    • Where the bits in the significant represent numbers in the range 0 to 1 and E specifies the value in the exponent field, see later)
    • If the significant bits are S1, S2, S3, etc. from left to right then:
    • (-1)Sx(1+(S1x2 -1 )+(S2x2 -2 )+(S3x2 -3 )+(S4x2 -4 )+...)x2 E
    Number Bases
  • 35.
    • The designers of the standard wanted integer operations to be able to test for sign that is why the sign bit is the left most bit. The next test for size would be the exponent. The greater the exponent the large the number. This is why the exponent appears next. If sign and exponent were the same the significant would then be compared.
    • Problems arise when we wish to compare numbers with negative exponents:
    Number Bases
  • 36.
    • e.g.
    • The number 0.5 would be represented as 1.0 x 2 -1 i.e.
    • 0|11111111|00000000000000000000000
    • The 1 in the significant is implicit and the -1 in the exponent is 2’s complement.
    • The number 2 would be represented as 1.0 x 2 1 i.e.
    • 0|00000001|00000000000000000000000
    • Using this format the number 0.5 would appear to have a greater value than 2. This would cause unacceptable difficulties.
    • The notation used must therefore adopt a system that uses:
    • 00000000 to represent the most negative exponent and
    • 11111111 to represent the most positive exponent.
    Number Bases
  • 37.
    • This is called a biased notation with the bias being the number subtracted from the normal unsigned representation to determine the real value.
    • IEEE uses a bias of 127 for single precision so the exponent -1 is represented by the value
    • -1 + 127 or 126 = 01111110 and the value exponent +1 would be +1 + 127 or 128 = 10000000
    • This means that the value represented by the floating point number is really
    • (-1) S x (1 + significant) x 2 (exponent - bias)
    • The exponent bias for single precision is 127 for double precision 1023.
    Number Bases
  • 38.
    • Convert the following numbers into single precision floating point notation:
    • a) -0.75 b) 2000 c) 123456.789
    • What number does the following single precision number represent:
    • 1|10000010|11000110000000000000000
    Number Bases
  • 39. This resource was created by the University of Wales Newport and released as an open educational resource through the Open Engineering Resources project of the HE Academy Engineering Subject Centre. The Open Engineering Resources project was funded by HEFCE and part of the JISC/HE Academy UKOER programme. © 2009 University of Wales Newport This work is licensed under a Creative Commons Attribution 2.0 License . The JISC logo is licensed under the terms of the Creative Commons Attribution-Non-Commercial-No Derivative Works 2.0 UK: England & Wales Licence.  All reproductions must comply with the terms of that licence. The HEA logo is owned by the Higher Education Academy Limited may be freely distributed and copied for educational purposes only, provided that appropriate acknowledgement is given to the Higher Education Academy as the copyright holder and original publisher. The name and logo of University of Wales Newport is a trade mark and all rights in it are reserved. The name and logo should not be reproduced without the express authorisation of the University. Number Bases