Computer Numbering System

Humans and computers have different ways of identifying , counting and manipulating   numbers. Identifying and counting numbers by human varies from simple to complex , suppose you are to find the total numbers of students in a class,  you start by counting 1 … n and not n …. 1 , the last number ( n ) of the student  is unknown. Similarly computers have a specific way of identifying, counting and manipulating number. Number systems  are used on software projects that requires close interaction with machine-level hardware, projects like ( System OS, networking, compilers , database system and applications requiring high performance ). Normally when an integer is written ( such as 25, or – 25 ) in Java or any high level program, the number is assumed to be in the decimal ( i.e base 10 ), by base 10 it mean the digits in the decimal number system are 0,1,2…9, having it’s lowest digit as 0 and highest digit as 9.

This article explains what is computer number system (CNS), different types of CNS, digits and positional value of each CNS, manipulation and conversion of various CNS and application of CNS.

  • What is computer number system ( CNS ) ?

Computer Number systems are techniques use to represent numbers in the computer system architecture, every value that you are saving or getting into/from computer memory has a defined number system.

  • Four types of CNS
  1. Binary number system
  2. Octal number system
  3. Decimal number system
  4. Hexadecimal (hex) number system

 

Binary NS  : All computers devices relies relies upon binary number ( 0 and 1 ).
However number input given to a computer are always in decimal system , but it is converted in binary so computer  understands the entered value and at the time of output it is again converted to decimal value. The lowest digit is 0 and highest digit is 1

Octary NS  : The digits range from 0 – 7 , because both binary and octary NS have fewer digits than the decimal NS. The lowest digit is 0 and highest digit is 7

Decimal NS  : The digits range from 0 – 9, the lowest digit is 0 and highest digit is 9.

Hexadecimal NS  : It includes 16 digits, with a lowest digit of 0 and a highest digit with a value equivalent to decimal 15 ( one less than 16 ), by convention letter A – F are use to represent the hexadecimal digits corresponding to 10 – 15.The lowest digit is 0 and highest digit is F

 

 

 

                                             NS  Table

Number Type          Values                   Base     Lowest|Highest value

Decimal :            0 ... 9                 base of 10    0  |  9

Binary :             0 and 1                 base of 2     0  |  1

Octary :             0 - 7                   base of 8     0  |  8

Hexa decimal :       0 ... 9 - A ... F       base of 16    0-9 | A- F

 

                                                FIRST 16 SYSTEM NUMBERS

  Decimal             Binary              Octary               Hexa Decimal

  0                     0                   0                      0
  1                     1                   1                      1
  2                                         2                      2 
  3                                         3                      3
  4                                         4                      4
  5                                         5                      5 
  6                                         6                      6  
  7                                         7                      7 
  8                                                                8 
  9                                                                9
  10...............................................................A                                                     
  11...............................................................B             
  12...............................................................C        
  13...............................................................D
  14...............................................................E
  15...............................................................F

 

  • Manipulation and conversion of various CNS

Suppose we have  int result_in_decimal = 78; // in decimal, the binary equivalent  is = 1001110 , octa dec = 116 , hex dec =  4E;

The calculation is as below

Points to notes

  1. When the base of a given is greater than the unknown base, use the unknown base to divide the given value , ensure your result ( whole number ) of each division is less than the unknown base , continue dividing till you reach the lowest value that is < -1 of the unknown base .

 

Base 10 is greater than base 2

78 / 2   =  39      ( 0 left )                   39   * 2  +  0 = 78

39 / 2   =  19      ( 1 left )                    19  * 2  +  1 = 39

19/2     =  9        ( 1 left )                    9     * 2  +  1 = 19

9/2       =  4        ( 1 left )                     4     * 2  +  1 = 9

4/2       =  2        ( 0 left )                     2     * 2  +  0 = 4

2/2       =  1        ( 0 left )                     1     * 2  +  0 = 2

 

Stop at where your division result is equivalent to the unknown base – 1 ( 2 – 1  = 1 ).

The  last division result is  1 ( which is equivalent to the highest value of a binary number  ).

Write the result from the bottom   (  1 0 0 1 1 1 0 )

 

  1. n the base of a given value is less than the unknown base, multiply the given value with the given base ( with ascending power ), ensure your result ( whole number ) of each multiplication is less than the unknown base , continue multiplying till you reach the lowest value that is < -1 of the unknown base .

 

Base 2 is less than base 8

 

1 *         =  64      ( 0 left )                             39   * 2  +  0 = 78

0 *         =  32      ( 1 left )                              19  * 2  +  1 = 39

0 *         =  16        ( 1 left )                            9     * 2  +  1 = 19

1 *         =  8        ( 1 left )                              4     * 2  +  1 = 9

1 *         =  4        ( 0 left )                              2     * 2  +  0 = 4

1 *         =  2        ( 0 left )                              1     * 2  +  0 = 2

0 *         = 0

Stop at where your division result is equivalent to the unknown base – 1 ( 2 – 1  = 1 ).

 

The  last division result is  1 ( which is equivalent to the highest value of a binary number  ).

 

Apllication

 

1. Decimal NS : Sse in our day-to-day activities

2.Binary NS : All computer language and programming is based on
the 2-digit number system used in digital encoding, example, the images you see on your computer screen
have been encoded with a binary line for each pixel. If a screen is using a 16-bit code, then each pixel
has been told what color to display
based on which bits are 0s and which bits are 1s. As a result, 2^16 represents 65,536 different colors!

3. Octary NS :

4. Hexadecimal NS :

You may read this Charles Petzold’s Code; a great book that uses very lucid metaphors for explaining computing concepts.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: