Computers store data in binary, you maybe asking what is binary. Binary is a number system composed of only two digits, "0" and "1". The circuits in a computer's processor are made up of billions of transistors . A transistor is a tiny switch that is activated by the electronic signals it receives. The digits 1 and 0 used in binary reflect the on and off states of a transistor. Binary can represent all values. Below is a table which can be used for turning denary numbers ( 1,2,3,4,5 etc..) into binary.
Example
Here is an example of how to turn the denary number of 54 into binary.
We are going to convert the number 173 to binary
Draw out the table shown above, this will help you to convert it
Does 128 go into 173, yes, so put a 1 in the space below 128
Now subtract 128 from 173 which leaves us with 45
Move onto the next number on the table which is 64
Does 64 go into 45, no, so put a 0 there
The next number is 32, does 32 go into 45 yes, now put a 1
Now subtract 32 from 45 which leaves us with 13
The next number is 16, does 16 go into 13, no, so leave a 0 there
The next number is 8, does 8 go into 13, yes, so put a 1 there
Now subtract 8 from 13, which leaves us with 5
The next number is 4, does 4 go into 5, yes, so put a 1 there
Now subtract 4 from 5, which leaves us with 1 now
The next number is 2, does 2 go into 1, no, so leave a 0 there
The next number is 1, does 1 go into 1,yes, so put a 1 there
You are now finished and should have the binary number 10101101
To convert the decimal number 173 into binary using the division by 2 method:
Divide the decimal number by 2. Write down the remainder (either 0 or 1) to the right of the previous remainder.
Repeat the process until the decimal number is equal to zero.
The binary representation is the combination of remainders read from bottom to top.
Example:
Convert the decimal number 173 into binary:
173 ÷ 2 = 86 with a remainder of 1
86 ÷ 2 = 43 with a remainder of 0
43 ÷ 2 = 21 with a remainder of 1
21 ÷ 2 = 10 with a remainder of 1
10 ÷ 2 = 5 with a remainder of 0
5 ÷ 2 = 2 with a remainder of 1
2 ÷ 2 = 1 with a remainder of 0
1 ÷ 2 = 0 with a remainder of 1
The binary representation of 173 is 10101101.
Hexadecimal (also known as hex) is a base-16 number system used in computing. Unlike the decimal (base-10) system, which uses 10 digits (0-9), the hexadecimal system uses 16 symbols to represent values (0-9, A-F), where A represents 10, B represents 11, C represents 12, D represents 13, E represents 14 and F represents 15. It's often used to represent large binary values more compactly
On the left is the base-16 number system
0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
Here's an example to convert decimal number 100 to hexadecimal:
Divide 100 by 16, 100 ÷ 16 = 6.25
Put 6 as decimals cannot be written in a hexadecimal number
Now times 16 by 6 to get the total of the first part, 16*6 = 96
Now subtract that from the original value you want to covert
100-96=4
So put 4 down
You should now have 64 as your Hexadecimal number
Try converting 42 into Hexadecimal
Answer - 2A
To get this answer you would have had to do these steps:
Divide 42/16, which is 2
Put 2 as the first Number
16*2=32, 42-32 = 10, so the second digit needs to be 1
But we can not write 10 as it is not on the base 16 system, instead we put A which represents 10.
So you would have 2A as your final answer.
Here's an example to convert hexadecimal number 64 to decimal:
Multiply the first hexadecimal digit 6 by 16: 6 x 16 = 96.
Add the second hexadecimal digit 4: 96 + 4 = 100.
The result 100 is the decimal equivalent of the hexadecimal number 64.
Binary arithmetic is a method of performing arithmetic operations using binary numbers.
Here is an example of how to perform binary addition:
Convert the decimal numbers to binary.
Write down the binary numbers so that their least significant bits are aligned.
Starting from the right-most bit, add the two binary numbers bit-by-bit.
If the sum is equal to or less than 1, write the result under the corresponding bit.
If the sum is equal to 2, write a 0 in the current bit and carry over 1 to the next bit.
Repeat the process for all bits.
Remember
1+0=1
0+1=1
1+1 = 10 (Carry 1 and place 0)
0+0= 0
1+1+1= Place 1 and carry 1
Overflow in binary addition occurs when the result of a binary addition operation is too large to be represented within the number of bits available. This results in an incorrect answer, as some of the most significant bits are lost.
Underflow in binary shift occurs when the shift operation moves all the bits of a binary number too far to the left or right, resulting in a loss of precision or a change in the sign of the number.
Adding the numbers 01011010 and 10001001 = 11100011
Binary Shift is an operation in computer science. It involves shifting the bits of a binary number to the left or right. This operation is used to multiply or divide a binary number by a power of 2.
There are two types of binary shift:
Left Shift: Shifting the bits of a binary number to the left. Each bit shifted to the left is equivalent to multiplying the number by 2.
Example:
Suppose we have the binary number 0101 (5 in decimal) and we perform a left shift by 2 bits.
The result would be 10100 (20 in decimal).
Right Shift: Shifting the bits of a binary number to the right. Each bit shifted to the right is equivalent to dividing the number by 2.
Example:
Suppose we have the binary number 1100 (12 in decimal) and we perform a right shift by 2 bits.
The result would be 0011 (3 in decimal).
A binary shift 2 places to the left has been performed on the binary number 00011010. The final number is 01101000 .This gives the effect of multiplying by 4
A binary shift 2 places to the right has been performed on the binary number 00011010. The final number is 00000110 .This gives the effect of dividing by 4
A binary shift 2 places to the left has been performed on the binary number 01101010 The final number is 10101000 .This gives the effect of multiplying by 4