1 / 39

3.1 Denary, Binary and Hexadecimal Number Systems

3.1 Denary, Binary and Hexadecimal Number Systems. We use the denary (base 10) number system in our daily life for counting and calculation. Computers use the binary (base 2) number system for data representations and manipulations.

joanmbrown
Download Presentation

3.1 Denary, Binary and Hexadecimal Number Systems

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. 3.1 Denary, Binary and Hexadecimal NumberSystems • We use the denary (base 10) number system in our daily life for counting and calculation. • Computers use the binary (base 2) number system for data representations and manipulations. • Programmers use hexadecimal (base 16) number system to communicate with computers.

  2. 3.1 Denary, Binary and Hexadecimal Number    Systems Different representations of number values from 0 to 9 using denary, binaryand hexadecimal number systems

  3. 3.1 Denary, Binary and Hexadecimal Number    Systems Different representations of number values from 10 to 15 using denary, binaryand hexadecimal number systems

  4. 3.1 Denary, Binary and Hexadecimal Number    Systems Different representations of number values from 10 to 15 using denary, binaryand hexadecimal number systems

  5. 3.2 Number System Conversion • From a Binary Number or a Hexadecimal Number to a Denary Number • By evaluating the place values of the digits of a binary number or hexadecimal number, we can find the corresponding values in the denary number system. Binary to Denary Hexadecimal to Denary

  6. 3.2 Number System Conversion • From a Binary Number or a Hexadecimal Number to a Denary Number • Binary to Denary • Only digits 0 and 1 are used in the binary number system. • The binary number 10112 in its expanded form is: Therefore, 10112 = 1 × 23 + 0 × 22 + 1 × 21 + 1 × 20 = 1110

  7. 3.2 Number System Conversion • From a Binary Number or a Hexadecimal Number to a Denary Number • Hexadecimal to Denary • In the hexadecimal number system, the digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E and F are used. • A, B, C, D, E, F represent 10, 11, 12, 13, 14, 15 respectively. • The hexadecimal number 2CA916 in its expanded form is: Therefore, 2CA916 = 2 × 163 + C × 162 + A × 161 + 9 × 160 = 1143310

  8. 3.2 Number System Conversion • From a Denary Number to a Binary Number or a Hexadecimal Number • To convert a denary number to another number system with base b: 1.Divide the denary number by b repetitively until the quotient is smaller than b. 2.Obtain the answer by writing up from the quotient to the remainders in reverse order.

  9. 3.2 Number System Conversion • From a Binary Number to a Hexadecimal Number • To convert a binary number into a hexadecimal number: 1.Group the digits of the binary number by four starting from the righthand side. 2.Replace each group of the four digits by an equivalent hexadecimal digit.

  10. 3.2 Number System Conversion • From a Hexadecimal Number to a Binary Number • To convert a hexadecimal number into a binary number: 1.Convert each digit of the hexadecimal number into a group of four binary digits. 2.Obtain the binary number by grouping all the binary digits together. • The big problem with the binary system is verbosity. For example: • A decimal value 202 requires 8 binary digits, making it difficult to read and remember. • Hexadecimal numbers are much more compact than binary numbers and it is easy to convert from a hexadecimal number to a binary number and vice versa.

  11. 3.2 Number System Conversion • From a Hexadecimal Number to a Binary Number • To convert a hexadecimal number into a binary number: 1.Convert each digit of the hexadecimal number into a group of four binary digits. 2.Obtain the binary number by grouping all the binary digits together. • The big problem with the binary system is verbosity. For example: • A decimal value 202 requires 8 binary digits, making it difficult to read and remember. • Hexadecimal numbers are much more compact than binary numbers and it is easy to convert from a hexadecimal number to a binary number and vice versa.

  12. 3.3 Number Representation in Computer Systems • Binary number system • the only number system that a computer uses in storing numbers and performing arithmetic • Bit, Byte and Word • Bit • A single binary digit • The basic unit for storing data in a computer • A single bit can only represent two distinct values. For example: • 0 or 1, True or False, On or Off • If more distinct values need to be represented, a series of bits can be used. For example: • A 8-bit binary number can hold 256 distinct values. • An n-bit binary number can represent 2n distinct values.

  13. 3.3 Number Representation in Computer Systems • Bit, Byte and Word • Byte • A data unit used in computers • Consists of 8 bits and is the smallest addressable unit in a microprocessor. Measurement units of data

  14. 3.3 Number Representation in Computer Systems • Bit, Byte and Word • Word • Modern computers can handle data stored in two or more bytes at a time. • The natural unit of data used by a computer is called a word. • The word length (word size) is measured in bits. • Modern computers usually have a word length of 16, 32 or 64 bits.

  15. 3.3 Number Representation in Computer Systems • Representation of Unsigned Binary Integer • Unsigned integer is a type of integer representation that contains no sign symbol. • Non-negative integers such as population and sales volume of books can be represented by unsigned integers. • All bits in a word are used to represent the magnitude.

  16. 3.3 Number Representation in Computer Systems • Representation of Unsigned Binary Integer Minimum and maximum unsigned values of various word lengths

  17. 3.3 Number Representation in Computer    Systems • Representation of Signed Binary Integer • Two common methods to represent signed binary integers: Sign-and-magnitude Two’s complement

  18. 3.3 Number Representation in Computer Systems • Representation of Signed Binary Integer • Sign-and-magnitude • The leftmost bit, known as sign bit, is used to specify the sign of a binary integer. • The sign bit: • 0: a positive integer • 1: a negative integer • The rest of the bits are used to store the magnitude of the binary number.

  19. 3.3 Number Representation in Computer Systems • Representation of Signed Binary Integer • Sign-and-magnitude Minimum and maximum values represented by sign-and-magnitude integers indifferent word lengths

  20. 3.3 Number Representation in Computer Systems • Representation of Signed Binary Integer • Sign-and-magnitude • The shortfall is that there are two representations of zero: • Both 1000 00002 and 0000 00002 represent zero in an 8-bit signed binary integer. • It is rarely used in computer systems.

  21. 3.3 Number Representation in Computer Systems • Representation of Signed Binary Integer • Two’s Complement • Widely used in computers to represent binary integers • All integers have unique representations. Two’s complement of a 4-bit integer

  22. 3.3 Number Representation in Computer Systems • Representation of Signed Binary Integer • Two’s Complement • Representation of a positive binary integer is exactly the same as that of the original value • To get a negative binary integer: • Starting from the corresponding positive binary integer, invert all bits from ‘0’ to ‘1’ and ‘1’ to ‘0’ . The result is known as one’s complement. • Add 1 to the one’s complement. • The above steps can also be used to convert a negative binary integer into a positive binary integer.

  23. 3.3 Number Representation in Computer Systems • Representation of Signed Binary Integer • Two’s Complement Minimum and maximum two’s complement values and their corresponding denary values of various word lengths

  24. 3.3 Number Representation in Computer Systems • Representation of Signed Binary Integer • Two’s Complement Minimum and maximum two’s complement values and their corresponding denary values of various word lengths

  25. 3.4 Addition and Subtraction of Different Number Representations • Addition and Subtraction of Unsigned Integers • The calculation on both addition and subtraction of unsigned integers in other number systems is the same as that in the denary system. • A ‘carry’ is generated when the sum of digits equals or exceeds the base value. • A ‘borrow’ from the left digit is necessary if a larger digit is subtracted from a smaller one.

  26. 3.4 Addition and Subtraction of Different Number Representations • Addition and Subtraction of Unsigned Integers • Overflow Error • Occur when the calculation result is outside the range that the digits can represent. For example: 1111 0000 +_ 0001 1100 1 0000 1100 1 0000 1000 – _ 0001 1000 11110000 Carry digit cannot be stored in the resulting bit pattern. Borrow occurs to the left of the leftmost bit. Examples of overflow errors

  27. 3.4 Addition and Subtraction of Different Number Representations • Addition and Subtraction of Two’s Complement Numbers • No matter what the sign bits are, the addition of two’s complement numbers are exactly the same as the addition of two unsigned binary integers. • Overflow error occurs when two numbers of the same sign are added and the result has the opposite sign.

  28. 3.4 Addition and Subtraction of Different Number Representations • Addition and Subtraction of Two’s Complement Numbers • No matter what the sign bits are, the addition of two’s complement numbers are exactly the same as the addition of two unsigned binary integers. • Overflow error occurs when two numbers of the same sign are added and the result has the opposite sign.

  29. 3.5 Character Coding Systems • Other than numeric data, a computer needs to store and process characters. • The character coding system is a way to represent characters in a form that can be manipulated efficiently in a computer.

  30. 3.5 Character Coding Systems • ASCII • Two common character coding systems: • American Standard Code for Information Interchange (ASCII) • Extended Binary-Coded Decimal Interchange Code (EBCDIC) • Each code represents either a printable character or a non-printable character (e.g. end-of-line character) • Each ASCII character consists of 7 bits, and it can contain 27(i.e. 128)different characters. • They include all the alphanumeric characters (the smalland capital English letters, digits from 0 to 9) and graphics symbols.

  31. 3.5 Character Coding Systems • ASCII ASCII code table

  32. 3.5 Character Coding Systems • ASCII ASCII code table

  33. 3.5 Character Coding Systems • ASCII • In practice, the 7-bit ASCII code is often embedded in an 8-bit code, where the leftmost bit is set as ‘0’. ASCII code table

  34. 3.5 Character Coding Systems • Chinese Character Coding Systems • The standard ASCII: 128 characters • The extended ASCII: 256 characters • There are more than 100,000 Chinese characters and we use more than 10,000 of them in our daily lives. • Chinese characters are usually represented in: • Big5 code • Guo Biao (GB) code • Unicode

  35. 3.5 Character Coding Systems • Chinese Character Coding Systems • Big5 code: traditional Chinese • GB code: simplified Chinese • Both character coding systems use two bytes to represent one Chinese character. • If a Chinese text file is processed with the wrong coding system, strange and meaningless characters will appear.

  36. 3.5 Character Coding Systems • Chinese Character Coding Systems Examples of Chinese characters represented in Big5 code and GB codes

  37. 3.5 Character Coding Systems • Unicode • Used to represent all the existinglanguages in the world • Contain about 100,000 characters • The representations of Unicode known as code points are variable in length. • Made up of one to four bytes • The code points are carefully defined so that the most frequently used characters, such as the ASCII codes, are put at the front of the code table. • These characters can be represented by a one-byte code point.

  38. 3.5 Character Coding Systems • Unicode Examples of Unicode

  39. 3.5 Character Coding Systems • Unicode Examples of Unicode

More Related