Constructing the 3 digit 10s complement code
 

We will now figure the mapping between any 3 digit number and its signed value:

   3 digit number        Signed value
   --------------      --------------    
      000         <--->    ...
      001         <--->    ...
     

      999         <--->    ...
   

The mapping will have desirable computational properties !!

This mapping allows use to perform + and − operations independently (i.e., the values of the operands has no effect on the meaning of the operation !)

Driving the car and addition/subtraction
 

It's important that you understand that:

  • When the car drive forward 1 mile, we add 1 to the odometer code:

      forward 1 mile:  

  • When the car drive backward 1 mile, we subtract 1 from the odometer code:

      reverse 1 mile:  

Let's design the mapping between the 3 digit code and signed values
 

Problem description:   how to map all the 3 digit code to the signed values:
 


   3 digit
   10s compl code         000  001 002 003 ... 998 999
   (odometer code)               /   /   /   \   \
           
            +---+...+---+---+---+---+---+---+---+---+...+---+    
                   •••• ••• ••    ( )  •   ••  ••• ••••
                   -4  -3  -2  -1   0   1   2   3   4
  Signed value                    
   

 

The mapping will help us perform arithmetic operation better !!!

Comment:   we are mapping to values that are intrinsic (e.g.: •, ••, ... and •, ••, ...).
For convenience (brevity), I also wrote down the signed decimal number.

Let's design the mapping between the 3 digit code and signed values
 

Question:   what 3 digit code should we use to map the value ZERO to ?
 


   3 digit
   10s compl code      
   (odometer code)             
                                   ???
            +---+...+---+---+---+---+---+---+---+---+...+---+    
                   •••• ••• ••    ( )  •   ••  ••• ••••
                   -4  -3  -2  -1   0   1   2   3   4
  Signed value                    
   

 

Let's design the mapping between the 3 digit code and signed values
 

Answer:   000 because this odometer meter reading is when the car is new
 


   3 digit
   10s compl code      
   (odometer code)             
                                   000
            +---+...+---+---+---+---+---+---+---+---+...+---+    
                   •••• ••• ••    ( )  •   ••  ••• ••••
                   -4  -3  -2  -1   0   1   2   3   4
  Signed value                    
   

 

Let's design the mapping between the 3 digit code and signed values
 

Question:   what 3 digit code should we use to map the value ONE to ?
 


   3 digit
   10s compl code      
   (odometer code)             
                                   000 ???
            +---+...+---+---+---+---+---+---+---+---+...+---+    
                   •••• ••• ••    ( )   ••  ••• ••••
                   -4  -3  -2  -1   0   1   2   3   4
  Signed value                    
   

 

Let's design the mapping between the 3 digit code and signed values
 

Answer:   001 because 000 + 1 = 001 and also: 001 − 1 = 000
 


   3 digit
   10s compl code      
   (odometer code)             
                                   000 001
            +---+...+---+---+---+---+---+---+---+---+...+---+    
                   •••• ••• ••    ( )   ••  ••• ••••
                   -4  -3  -2  -1   0   1   2   3   4
  Signed value                    
   

 

So if 001 represents the value • (ONE), we can perform addition and subtraction "naturally" (i.e., the value of the operands do not change the meaning of the +/− operation !!)

Let's design the mapping between the 3 digit code and signed values
 

Question:   what 3 digit code should we use to map the value TWO to ?
 


   3 digit
   10s compl code      
   (odometer code)             
                                   000 001 ???
            +---+...+---+---+---+---+---+---+---+---+...+---+    
                   •••• ••• ••    ( )  •   ••  ••• ••••
                   -4  -3  -2  -1   0   1   2   3   4
  Signed value                    
   

 

Let's design the mapping between the 3 digit code and signed values
 

Answer:   002 because 001 + 1 = 002 and also: 002 − 1 = 001
 


   3 digit
   10s compl code      
   (odometer code)             
                                   000 001 002
            +---+...+---+---+---+---+---+---+---+---+...+---+    
                   •••• ••• ••    ( )  •   ••  ••• ••••
                   -4  -3  -2  -1   0   1   2   3   4
  Signed value                    
   

 

So if 002 represents the value •• (TWO), we can perform addition and subtraction "naturally"

Let's design the mapping between the 3 digit code and signed values
 

Question:   what 3 digit code should we use to map the value NEGATIVE ONE to ?
 


   3 digit
   10s compl code      
   (odometer code)             
                               ??? 000 001 002
            +---+...+---+---+---+---+---+---+---+---+...+---+    
                   •••• ••• ••    ( )  •   ••  ••• ••••
                   -4  -3  -2  -1   0   1   2   3   4
  Signed value                    
   

 

Let's design the mapping between the 3 digit code and signed values
 

Answer:   999 because 999 + 1 = 000 and also: 000 − 1 = 999
Read as the equation as: NEG ONE + 1 = ZERO and ZERO − 1 = NEG ONE


   3 digit
   10s compl code      
   (odometer code)             
                               999 000 001 002
            +---+...+---+---+---+---+---+---+---+---+...+---+    
                   •••• ••• ••    ( )  •   ••  ••• ••••
                   -4  -3  -2  -1   0   1   2   3   4
  Signed value                    
   

 

So if 999 represents the value (NEGATIVE ONE), we can perform addition and subtraction "naturally" (i.e., the value of the operands do not change the meaning of the +/− operation !!)

Let's design the mapping between the 3 digit code and signed values
 

Question:   what 3 digit code should we use to map the value NEGATIVE TWO to ?
 


   3 digit
   10s compl code      
   (odometer code)             
                           ??? 999 000 001 002
            +---+...+---+---+---+---+---+---+---+---+...+---+    
                   •••• ••• ••    ( )  •   ••  ••• ••••
                   -4  -3  -2  -1   0   1   2   3   4
  Signed value                    
   

 

Let's design the mapping between the 3 digit code and signed values
 

Answer:   998 because 998 + 1 = 999 and also: 999 − 1 = 998
Read as the equation as: NEG TWO + 1 = NEG ONE and NEG ONE − 1 = NEG TWO


   3 digit
   10s compl code      
   (odometer code)             
                           998 999 000 001 002
            +---+...+---+---+---+---+---+---+---+---+...+---+    
                   •••• ••• ••    ( )  •   ••  ••• ••••
                   -4  -3  -2  -1   0   1   2   3   4
  Signed value                    
   

 

So if 998 represents the value •• (NEGATIVE TWO), we can perform addition and subtraction "naturally" (i.e., the value of the operands do not change the meaning of the +/− operation !!)

Let's design the mapping between the 3 digit code and signed values
 

And so on:  
 


   3 digit
   10s compl code      
   (odometer code)             
                   996 997 998 999 000 001 002 003 004
            +---+...+---+---+---+---+---+---+---+---+...+---+    
                   •••• ••• ••    ( )  •   ••  ••• ••••
                   -4  -3  -2  -1   0   1   2   3   4
  Signed value                    
   

 

Question:   where should we stop ???

Equal proportion representation:   we want represent a (approximately) same number of positive values and negative values

Let's design the mapping between the 3 digit code and signed values
 

The 3 digit 10s complement code mapping onto the set of signed value [-500..499] is as follows:
 


   3 digit
   10s compl code      
   (odometer code)             
           500     996 997 998 999 000 001 002 003 004     499
            +---+...+---+---+---+---+---+---+---+---+...+---+    
                   •••• ••• ••    ( )  •   ••  ••• ••••
          -500     -4  -3  -2  -1   0   1   2   3   4      499
  Signed value                    
   

 

Representing large signed integer (whole number) values

  • The 3 digits 10s complement code can only represent this range of (signed) values:

     3 digits 10 compl code:    500     998 999 000 001 002     499
                                 +---+...+---+---+---+---+...+---+       
     signed-magnitude code:    -500     -2  -1   0   1   2      499
    

  • I used a 3 digits 10s complement code to explain the encoding/decoding method of the 10s complement code

  • For practical use (i.e.: to represent real life values), we must use more digits in the 10s complement code

    Example:

    • Use a 20 digits 10s complement code

      The range of numbers represented is: -500000000000000000000 ........ 499999999999999999999

Let's see what the 10s complement code can do for us - next