NUMBER SYSTEMS
AND CODE
   NUMBER SYSTEMS
• There are several number systems that exist, the most
 common are the following:
 •Decimal   34510
 •Binary  1001100102
 •Octal   45728
 •Hexadecimal 3AD67816
 •NOTE: To avoid confusion, the base of each individual
 number may be as specified by writing it as a subscript of
 the number
     DECIMAL NUMBER SYSTEM
• Made up of 10 digits 0,1,2,3,4,5,6,7,8,9
• Base 10 or Decimal Base
To decompose a decimal base number,
 we multiply each digit with his weight
• For example:
Binary Number system
•   Uses 2 symbols/digits: 0, 1
•   Binary Base (or Base 2)
•   Read as:
•   One Zero One One, base Two
•   Decomposition of the Number
Converting Binary to Decimal
To convert a binary number to decimal,
we multiply each digit with his weight
and sum them.
OCTAL NUMBER SYSTEM
•   Uses 8 symbols/digits: 0, 1, 2, 3, 4, 5, 6, 7.
•   OCTAL Base or (Base 8)
Read as:
One Four Five Three, base Eight or
Octal One Four Five Three
•   Decomposition of the Number
OCTAL NUMBER SYSTEM
•   Provides an easier way of representing binary number with many digits because 1
    octal digit equals 3 binary digits
•   To convert an OCTAL number to decimal we multiply each digit with its weight
    and sum them up
Hexadecimal number system
•   Uses 16 symbols/digits:
•   0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.
•   Hexadecimal base or (Base sixteen)
HEXADECIMAL NUMBER SYSTEM
•   Makes it even easier to represent large
binary numbers (an hexadecimal
represents a 4 digit binary);
•   Decomposition and conversion of hexadecimal to decimal follow the same rules as
    the other number systems
•   Example: ABC416 = A x 163 + B x 162 + C x 161 + 4 x 160
                     =10 x 163 +11 x 162 + 12 x 161 + 4 x 160 = 43972
Converting FROM decimal TO binary
systems
•   To convert from Decimal to binary: The decimal number is divided by number 2.
    The remainder is the LSD
•   The result is again divided by two, and its
          remainder is the next least significant bit;
•   This process continues until the result
               cannot be divided anymore and the last
                        result is the most-significant bit (MSD).
Converting from decimal to octal
Converting from decimal to
HEXIDECIMAL
Assignment 1
1.       Read On The Following
     •   Fractional Decimal Conversion i.e. Converting fractional Decimal to Binary, Octal,
         Hexadecimal
     •   Binary Coded Decimals (BCD), Digital Codes
     •   Error Detection Codes
     •   Logic Gates (NOT, AND, OR, NAND, NOR, XOR,X-NOR)
Number systems and code 2
•   Decimal System Conversion
•   Binary System Conversion
•   Binary Arithmetic
•   Binary Coded Decimals
•   Digital Codes
Decimal conversion
•   Conversion to Binary and Back
    •   (Fractional)
•   Conversion to Octal and Back
    •   (Fractional)
•   Conversion to Hexadecimal and Back
•   (Fractional)
Conversion to Binary System
•   We use the Repeated Division by 2 Method. The Best way to explain is through the
    following example
•   To convert the decimal number 12 to binary, begin by dividing 12 by 2. Then divide
    each resulting quotient by 2 until there is a 0 whole number quotient. The
    remainders generated by each division form the binary.
•   Therefore 1210 =11002
Conversion to Binary System
Converting back to decimal from binary
To convert a binary number to decimal,        we multiply each digit with its weight
and sum them.
•   11002 = 1 x 23 + 1 x 22 + 0 x 21 + 0 x 20 = 8+4+0+0 =1210
Fractional decimal conversion to binary
•   We use the repeated-multiplication-by-2 method i.e. Decimal fractions can be
    converted to binary by repeated multiplication by 2.
•   To convert 0.312510 to binary for example, begin by multiplying by 2, then multiply
    each resulting fractional part of the product by 2 until the fractional product is
    zero, and until the desired number of decimal places is reached.
•   The carry digits generated by multiplication produce the binary number. The first
    carry being the MSB and the last carry being the LSB
Fractional decimal conversion to binary
•   0.3125 x 2 = 0.625 C = 0 (MSB)
•   0.625 x 2   = 1.25      C=1
•   0.25 x 2 = 0.50      C=0
•   0.50 x 2    = 1.00      C = 1 (LSB)
•   Therefore 0.312510 = 0.01012
QUESTION
•   How Do You Convert Fractional Binary Back to Decimal e.g. 0.1110 ?
ANS: By applying the same rules i.e. multiply each digit with its weight
 and sum them.
(EXAMINABLE)
Conversion to octal and hexadecimal
systems
•   The same method used to convert decimal numbers to binary system is applicable
    to both octal and hexadecimal systems.
•   The only difference is using number 8 or 16 instead of 2 for octal or hexadecimal
    system respectively
•   The also applies to fractional numbers
Fractional decimal to Octal or HEX
•    Take a fractional part of the number (i.e. integer part equals to zero)
1.     STEP1: Multiply by 8 /16
2.     STEP2: Record the integer part down
3.     STEP3: Go to step 1
    CONVERTING PI TO HEXADECIMAL
•   0.14159265358979 x 16 =                   •    0.96350910377984 x 16 =
    2.26548245743664;                             15.41614566047744;
•   int part 2 (0x2); frac 0.26548245743664   •   int part 15 (0xF); frac 0.41614566047744
•    0.26548245743664 x 16 =                  •    0.41614566047744 x 16 =
    4.24771931898624;                             6.65833056763904;
•   int part 4 (0x4); frac 0.24771931898624   •   int part 6 (0x6); frac 0.65833056763904
•    0.24771931898624 x 16 =                  •    0.65833056763904 x16 =
    3.96350910377984;                             10.53328908222464;
•   int part 3 (0x3); frac 0.96350910377984   •   int part 10 (0xA); ...
      pi (hexadecimal) = 3.243F6A...
QUESTIONs/further study
•   How Do You Convert Fractional Hexadecimal/Octal Back to Decimal ?
ANS: By applying the same rules i.e. multiply each digit with its weight
 and sum them.
(EXAMINABLE)
BINARY ARITHMETIC
•   Addition
•   Subtraction
•   Multiplication
•   Division
BINARY ADDITION
•   Four basic rules exist:
•   0 + 0 = 0 Sum of 0 with carry of 0
•   0 + 1 = 1 Sum of 1 with carry of 0
•   1 + 0 = 1 Sum of 1 with carry of 0
•   1 + 1 = 10 Sum of 0 with carry of 1
•   When there is a carry of 1, it is transferred to the next column on the left
BINARY ADDITION
BINARY SUBTRACTION
BINARY MULTIPLICATION
BINARY DIVISION
There is no table, it is done by using multiplication and subtraction
    BINARY TO HEXADECIMAL Conversion
    and back
• To convert binary to hexadecimal break the binary number
  to 4-bit groups, starting with the right-most bit and replace
  each 4-bit group with the equivalent hexadecimal symbol.
• Example: a) 1100101001010111 = b) 1111110001011101001
• To convert back to binary from hexadecimal, you simply
 reverse the process, replacing each hex value with
 equivalent 4-bit
  1’s and 2’s complement of binary numbers
• The 1’s complement and the 2’s complement of a
binary number are important because they permit
the representation of negative numbers. The method
of 2’s complement arithmetic is commonly used in
computers to handle negative numbers
FINDING THE 1’S COMPLeMENT
• The 1’s complement of a binary number is found by
 changing all 1s to 0s and all 0s to 1s.
• The simplest way to obtain the 1’s compliment of a
 binary number with a digital circuit is to use parallel
 inverters
• Exercise: Find the 1’s complement of a) 00011010 b)
 11110111 c) 10001101
Finding the 2’s complement
• The 2’s complement of a binary number is found
  by adding 1 to the LSB of the 1’s complement
• 2’s complement = (1’s complement) +1
• Exercise: Find the 2’s complement of
• a) 00010110 b) 11111100 c) 10010001
Further study
•Signed Numbers
•Floating Point Number
•Arithmetic Operation with Signed Numbers
BINARY CODED DECIMALS (BCD)
• BCD is a away of expressing each    The representation of the
  of the decimal digits with binary   decimals 10, 11, 12, 13, 14 and 15 is
  code.                               excluded.
• 10 code groups in BCD system
  each representing a decimal digit
• The 8421 code is a type of BCD
  code indicating the binary weight
  of the four bits (23, 22, 21, 20)
BCD ADDITION
•   BCD can be used in arithmetic          •   2: If the 4-bit sum is equal to or less
    operation. We focus on Addition the        than 9 it is a valid BCD
    other operations can be accomplish
    using addition                         •   3: If it is greater than 9 the result is
                                               invalid. Add 6 (0110) to the 4-bit sum to
•   There are rules guiding BCD Addition       skip the 6 invalid states
•    1: Add the 2 BCD numbers, using the
    rules of binary addition
  DIGITAL CODES
•These are special   •Excess-3-code
 codes used in       •6311
 digital systems.    •2-out-of-5 code
 Few includes
•Gray Code
•ASCII code
•Unicode
Others:
   Gray code
•The Gray code is unweighted and is not an arithmetic code
 i.e. there are no specific weights assigned to bit positions.
•The important feature of Gray code is that, it exhibits only
 a single bit change from the code word to the next in the
 sequence.
•It is applied to shaft position encoders where error
 susceptibility increases with the number of bit changes
 between adjacent numbers in the sequence
GRAY CODE
BINARY-TO-GRAY CODE CONVERIOSN
• The conversion follows the   1.   Going from Left to right,
  following rules                   add each adjacent pair of
1. The MSB in the Gray code
                                    binary code bits to get the
   is the same as the               next gray code. DISCARD
   corresponding MSB in the         carries
   binary number
      GRAY-TO-BINARY CODE CONVERSION
• A similar method applies:      1.   Add each binary code bit
1.   The MSB in the binary            generated to the gray code
     number is the same as the        in the next adjacent
     corresponding bit in the         position. DISCARD carries
     gray code
    ASCII & ALPHANUMERIC CODES
• Alphanumeric codes are code that represent numbers and
 alphabetic characters (letters). In most cases such codes also
 represent other characters such as symbols and instructions
 necessary in conveying information.
• ASCII abbrv for AMERICAN STANDARD CODE FOR
 INFORMATION INTERCHANGE is a universally accepted
 alphanumeric code used in most computers and other
 electronic equipment
ASCII
• ASCII can be seen as a     • The first 32 characters are
  subset of Unicode            nongraphic commands
• Has 128 characters and       and used for control
  symbols represented by a     purposes. The remaining
  7-bit code (0x00- 0x7F)      are graphic including
                               alphabet(upper and lower
                               cases), 10 decimal digits,
                               punctuation signs and
                               other commonly used
                               symbols
                             • The first 32 characters are
                               used to allow devices
Extended ASCII
• Has additional 128 characters from ASCII and represented
  by 8-bit code series from 0x80 to 0xFF
• Adopted by IBM for their personal computers until it
  became popular.
• Now used in applications other than PCs
• Contains foreign alphabetic characters, foreign currency
  symbols, Greek characters, mathematical symbols, drawing
  characters, bar graphing characters and shading characters
UNICODE
• Unicode provides the ability to encode all the characters
 used in written languages of the world by assigning each
 character
• Consist of about 100,000 characters, a set of code charts
 for visual reference, an encoding methodology and a set
 of standard character encodings, and an enumeration of
 character properties
  FURTHER STUDY
•Read on Error Checking Codes i.e.
•Parity Method of Error Correction
•Hamming Code
•Cyclic Redundancy Check
•Parity
THANK YOU FOR
  LISTENING