1 / 22

Information and Communication Technology

Information and Communication Technology. 3.3-3.4. CHAN CHOI FONG S. 4A (14). 3.3 Number Representation in Computer System. Binary number system is the only number system that computer uses in storing numbers. Bit (basic unit) is a single binary digit

uma-ashley
Télécharger la présentation

Information and Communication Technology

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Information and Communication Technology 3.3-3.4 CHAN CHOI FONG S. 4A (14)

  2. 3.3 Number Representation in Computer System • Binary number system is the only number system that computer uses in storing numbers. • Bit (basic unit) • is a single binary digit • any one of two different values can be represent,(for example: true /false ,on/off) • more different values need to represent-> use a series of bits (for example: 8-bit binary number have 256 different values)

  3. Byte • is a data unit used in computer • consist of 8 units

  4. Word • is a natural unit of data used by a computer • the number of bits that the computer can handle at one time (cycle) • word length ( = word size ) is measured in bits • the computer : 16, 32 or 64 bits

  5. Representation of unsigned binary integer • contains no sign symbol ( you can’t have a negative integer here) • in the computer : all bits are used to represent the magnitude

  6. Representation of signed binary integer • Sign-and-magnitude • 0 = positive integer and 1 = negative integer • 1000 00002 = 0000 00002 = 0

  7. Two’s complement • all integers have unique representations

  8. Convert to 2’s complement from the one’s complement • start from the positive integer • invert all bits from “ 0 ” to “ 1 ” and “ 1 ” to “ 0 ” • then you will find the negative integer • Add 1 into that integer eg. 0111 (decimal value : 7 ) 1000 + 1 = 1001 (decimal value : -7 ) 0011 (decimal value : 3 ) 1100 + 1 = 1101 (decimal value : -3 )

  9. Convert to two’s complement code directly • start from the positive integer • when you see the first “ 1 “ in the right side • at the back of the first “ 1 ”, invert all bits from “ 0 ” to “ 1 ” and “ 1 ” to “ 0 ” • then you will find the negative integer eg. 0101 (decimal value : 5 ) 1011 (decimal value : -5 )

  10. eg. 0100 (decimal value : 4 ) 1100 (decimal value : -4 ) • 0000 = 0

  11. Exercise • 0111 1101 (decimal value : 125 ) one’s complement of -12510 : 1000 00102 two’s complement of -12510 : 1000 00112

  12. 0100 1110 0101 0000 (decimal value : 20048 ) one’s complement of -632610 : 1011 0001 1010 11112 two’s complement of -632610 : 1011 0001 1011 00002

  13. The advantages of using 2‘s complement over sign-and-magnitude • No duplication of representation of zero • Much simpler circuit to handle calculation (no separated circuit is needed to handle the sign bit) • The range of numbers in two’s complement is wider than the sign-and-magnitude

  14. The advantages of using sign-and-magnitude 1. Easy for human to understand

  15. 3.4 Addition and subtraction of different number representations • Addition and subtraction of unsigned integers • “carry”: the sum if digits equals or exceeds the base value eg. Calculate 10102 + 11102 1 0 1 0 + 111111 0 1 1 0 0 0

  16. “borrow” : from the left digit is necessary if a larger digit is subtracted from a smaller one eg. Calculate 110102 - 11012 11 11 0 11 0 - 1 1 0 1 1 1 0 1

  17. overflow error : an error may occur when the result is outside the range eg. 1111 0000 10000 1000 + 0001 1100 - 0001 1000 1 0000 1100 1111 0000

  18. Addition and subtraction of two’s complement numbers • Overflow error just only occurs when two numbers of the same sign are added eg. Calculate -1110+ 2010 1111 0101 + 0001 0100 1 0000 0000 (they have different signs, overflow error will not occur)

  19. eg. Calculate -3310 - 6510 1101 1111 + 1011 1111 11001 1110 (the sign bit of the result is the same, so an overflow error does not occur)

  20. eg. calculate -3310 – 10010 1101 1111 + 1001 1100 1 0111 1011 (the sign bit of the result is different , so an overflow error occurs)

More Related