Types of Computer Number Systems: Binary and Decimal
Edited by TheGuyLoveNY, Jen Moreau, SarMal, Sharingknowledge
Binary Numbers
Binary numbers have a base number that is either 1s and 0s. Computers are heavily bounded with binary digits or bits. Memories are in bits as well, such as KB, MB, GB, TB, PB. It is interesting that computers have only two states, ON and OFF. These states are represented with 1 (ON) and 0 (OFF). When a number is passed from a memory location to another, say, for example, a = 4, the decimal number 1 is being assigned to a variable a. This decimal number is converted to bits : (0100)2 . The CPU signals a memory transfer. In this case, go to a memory where variable a is located. 0100 bits are assigned to variable a.
Well, that was easy, But the real question is, how does the computer know what is 1 and 0? The fact that the computer is an electronic device when power or electricity occurs, it is represented by. When no electric occurs means 0 (OFF). When assigning (0100) to "a", it has to be (OFF ON OFF OFF).
'Decimal Numbers
We use decimal numbers everywhere in our daily life. Digits from 0 to 9 are decimal numbers also known as denary. Humans work with decimal numbers but computers don't. As explained above, computers only work with binary numbers. Decimal numbers are converted to binary numbers to store them on computers. Whenever they are displayed on the screen, they are converted from binary to decimal numbers
Hexadecimal Numbers
Hexadecimal numbers are numbers with base 16 or hex. They are most commonly used by computer programmers. It has 0-9 digits and from there it is represented as A for 10, B for 11 and so on until F for 15.
Here is the Hexadecimal to binary number chart:
Binary Addition
Binary addition is pretty simple. Two binary numbers are added bit by bit.
- 1 + 1 = 0, 1 is borrowed to the next bit.
- 0 + 1 = 1
- 1 + 0 = 1
- 0 + 0 = 0
Example 1: Add (110 110)2and (1110001)2
The result : (1101111)2
2's Complement
2's complement is used to represent negative binary numbers in computer memory. Positive numbers are directly represented as is but negative numbers are represented using 2's Complement. 2's Complement makes use of 1's complement.
2's Complement works: Apply 1's complement. Add 1 bit to the bits. Now, 1's complement is nothing but inverting the bits, i.e 1 to 0 and vice versa.
For example: Represent (1101111)2 in 2's Complement.
- Step 1: Invert all the bits (1's Complement).
(1101111)2 >>>>> (0010000)2
- Step 2: Add 1 bit to the bits.
The 2's Complement of (1101111)2 is (0010001)2
Binary Subtraction
Binary subtraction is a bit different in bits. The steps in Binary subtraction:
Step 1: Convert the second's bits into 2's complement. Step 2: Add the two bits. Step 3: Neglect extra bit from the result (if any).
Example 1:
Subtract (10101)2and (01110)2
- Step 1: Take 2's complement of the 2nd value.
Invert all the bits and Add 1 bit to it.
01110 >>>>>>>>> 10001
(10001)2 + (00001)2 = (10010)2
- Step 2 : Add both the bits.
The Result: (00111)2
Example 2: Perform Binary Subtraction on 010101 and 101010
- Step 1: Apply 2's complement on second bits.
Invert all the bits : (101010) >>>>>>> (010101)
Now, Add 1 bit to the result : (010101) + (000001) = (010110)
- Step 2 : Add both the Bits.
(010101)2 + (010110)2
There was no extra bit to discard, Hence the Result: (101011)2
This article is part of a series on Computer Organization and Assembly Language (COAL). Read the full series here
1) Computer Organization and Assembly Language (COAL)
2) Number Systems
3) Overview of Computer Language Hierarchy
Referencing this Article
If you need to reference this article in your work, you can copy-paste the following depending on your required format:
APA (American Psychological Association)
Types of Computer Number Systems: Binary and Decimal. (2017). In ScienceAid. Retrieved Dec 18, 2018, from https://scienceaid.net/Number_Systems
MLA (Modern Language Association) "Types of Computer Number Systems: Binary and Decimal." ScienceAid, scienceaid.net/Number_Systems Accessed 18 Dec 2018.
Chicago / Turabian ScienceAid.net. "Types of Computer Number Systems: Binary and Decimal." Accessed Dec 18, 2018. https://scienceaid.net/Number_Systems.
If you have problems with any of the steps in this article, please ask a question for more help, or post in the comments section below.
Comments
Article Info
Categories : Computer Organization and Assembly Language
Recent edits by: SarMal, Jen Moreau, TheGuyLoveNY