Page 49 - Cs_withBlue_J_C11_Flipbook
P. 49

When you input text, the character encoding maps characters we choose to specific bytes in computer memory.
                 To output the same, it reads the bytes back into characters. A character encoding provides a key to unlock this binary
                 code. It is a set of mappings between the bytes in the computer and the characters in the character set.


                                                               Definition

                      Character encoding is a process of assigning numeric code to character set of different human languages across the
                      world, allowing them to be stored, computed, converted and transmitted using digital computers.





                     2.1 BINARY ENCODING FOR INTEGERS
                 Integers are the numbers without decimal point. They can be positive, negative or zero. Digital devices work on binary
                 integers which can be unsigned or signed. Unsigned binary numbers can represent positive values only and signed
                 binary numbers can represent both positive and negative values. Writing prefix + sign is not mandatory for positive
                 numbers. However, giving the ‘-’ sign before a negative number is compulsory.

                 In digital computers, a decimal number when converted internally to binary cannot have a + or - sign as digital circuits
                 have no such provision. So, the need for separate representation arises.
                 Thus, binary integers both unsigned and signed are represented in three ways which are as follows:

                 •  Signed magnitude notation
                 •  One’s complement notation
                 •  Two’s complement notation

                 2.1.1 Signed Magnitude Notation
                 The signed magnitude notation is the representation of a signed binary number. If the sign bit is “0”, the number is
                 positive. If the sign bit is “1”, then the number is negative.
                 Let us illustrate this with an example. Consider an integer number 67. Its binary equivalent is 1000011. Considering
                 8-bit byte, +67 and -67 will be represented as follows:

                                      +67     0       1      0      0       0      0      1       1
                                      -67     1       1      0      0       0      0      1       1
                                            Sign bit                    Value bits

                 So we see that in this representation with an n-bit field, the range of numbers that can be represented is:
                 -2 n-1  - 1 to 2 n-1  - 1

                 For example: if we have 8 bits to represent a signed binary number (i.e., 1-bit for the Sign bit and 7-bits for the
                 Magnitude bits), then the actual range of numbers we can represent in signed magnitude notation would be:
                 -2 (8-1)  - 1 to +2 (8-1)  - 1
                 -127 to +127


                                                                Definition

                      Signed magnitude notation is a way of representing binary numbers of ‘n’ bits by reserving 1 bit in leftmost MSB
                      for sign and remaining n-1 bits for the magnitude. The sign bit is assigned 0 for positive binary numbers and 1 for
                      negative numbers.





                                                                                                                        47
                                                                                                            Encoding    47
   44   45   46   47   48   49   50   51   52   53   54