ADVANCE DECIMAL-BINARY CALCULATOR FOR SIGNED INT
Enter value in
DECIMAL
S.B 👉Simple Binary(1st bit sign)
1's 👉1st complement of a negative integer
2's 👉2nd complement of a negative integer
DEFINING DIFFERENT NUMBER FORMAT
- Decimal
You are much more familiar with this system of number and counting no-body clearly knows how this decimal means 10th number system has evolved but it is fantastic. According to studies we have decimal number system may be due to we have 10 fingers in our hands. But not 100% sure as usual in history researches. In simple words it is just the number system which is 1,2....,9,10,...99,100....not ending 😎😎.
- SIMPLE BINARY
It is the first generation binary numbers used in computers for storing data but having a lot of cons.Two major fault is it is having two representation of zero I. e. 00 or 01 because in case of zero positive and negative does not matters (+0 = -0).And the second one is -it unnecessarily takes more bits to store same number than 1'st complement and 2'nd complement numbers because it contains a MSB that contains sign value only by taking 1 bit memory size .
- 1'st Complement
We can say that this number system is valid only if the integer is negative .What happens actually the memory saves a negative number just the opposite of its positive form in binary system.
Example
Represent -15 in 1'complement form.
Steps
- We will first bring positive out of given negative no. -15 ➡️ 15
- We will convert 15 to its binary representation 15 => 1111
- We will exchange all 1 with 0 and 0 with 1 and final answer is -15 in its first compliment form is 0000 "yahoo"
IMPORTANT:actually in memory the -15 will be saved as 11110000 if your compiler is accepting integer as 1 byte number but one confusion is will the computer not get confused while reading 11110000 as -15 or 240
Actually system saves these positive and negative binary numbers at different places but again you may have doubts that " what is the use of this number if system already saves + and - at different places here the answer is for easier calculation by system in 1 and 2 complement number system substraction of a number from another takes places directly like any binary addition (0+0=0,1+0=1,1+1=0 with carry 1).But 2nd compliment numbers have more profit that of 1 St compliment so we prefer it.
- 2nd Complement
So, finally we use second complement number system for storing negative numbers only because it easier to add these to a positive number .In this article we will not see how addition happens rather we will take a example of how to convert a integral negative number to its second compliment form.
Example
Convert -23 to its second complement form
Steps
- -23 ➡️ 23 (save only 23 ignore negative)
- Concert 23 to its binary number 10111
- Convert to its 1'st complement 01000
- Just add 1 with 01000 like binary addition and your answer is 01001
This one was just simple one without this we have one other scenarios of addition
- When we need to add 1 with 1 or when the left most bit in 1 complement is 1 in that case 1+1 =0 with carry 1 that is add carried one with next number.
Note here you may be in confusion that what we will do of we will get a carried one after all digits but thing is that this will not happen in any condition because if you have given a negative number convert it to positive and take only usable bits so obviously your left most bit will be 1in simple binary and 0 in 1 St complement and carried 1 will end-up here.

0 Comments