What are the required steps to convert base 10 integer
number -106 543 246 315 365 to signed binary code (in base 2)?
- A signed integer, written in base ten, or a decimal system number, is a number written using the digits 0 through 9 and the sign, which can be positive (+) or negative (-). If positive, the sign is usually not written. A number written in base two, or binary, is a number written using only the digits 0 and 1.
1. Start with the positive version of the number:
|-106 543 246 315 365| = 106 543 246 315 365
2. Divide the number repeatedly by 2:
Keep track of each remainder.
Stop when you get a quotient that is equal to zero.
- division = quotient + remainder;
- 106 543 246 315 365 ÷ 2 = 53 271 623 157 682 + 1;
- 53 271 623 157 682 ÷ 2 = 26 635 811 578 841 + 0;
- 26 635 811 578 841 ÷ 2 = 13 317 905 789 420 + 1;
- 13 317 905 789 420 ÷ 2 = 6 658 952 894 710 + 0;
- 6 658 952 894 710 ÷ 2 = 3 329 476 447 355 + 0;
- 3 329 476 447 355 ÷ 2 = 1 664 738 223 677 + 1;
- 1 664 738 223 677 ÷ 2 = 832 369 111 838 + 1;
- 832 369 111 838 ÷ 2 = 416 184 555 919 + 0;
- 416 184 555 919 ÷ 2 = 208 092 277 959 + 1;
- 208 092 277 959 ÷ 2 = 104 046 138 979 + 1;
- 104 046 138 979 ÷ 2 = 52 023 069 489 + 1;
- 52 023 069 489 ÷ 2 = 26 011 534 744 + 1;
- 26 011 534 744 ÷ 2 = 13 005 767 372 + 0;
- 13 005 767 372 ÷ 2 = 6 502 883 686 + 0;
- 6 502 883 686 ÷ 2 = 3 251 441 843 + 0;
- 3 251 441 843 ÷ 2 = 1 625 720 921 + 1;
- 1 625 720 921 ÷ 2 = 812 860 460 + 1;
- 812 860 460 ÷ 2 = 406 430 230 + 0;
- 406 430 230 ÷ 2 = 203 215 115 + 0;
- 203 215 115 ÷ 2 = 101 607 557 + 1;
- 101 607 557 ÷ 2 = 50 803 778 + 1;
- 50 803 778 ÷ 2 = 25 401 889 + 0;
- 25 401 889 ÷ 2 = 12 700 944 + 1;
- 12 700 944 ÷ 2 = 6 350 472 + 0;
- 6 350 472 ÷ 2 = 3 175 236 + 0;
- 3 175 236 ÷ 2 = 1 587 618 + 0;
- 1 587 618 ÷ 2 = 793 809 + 0;
- 793 809 ÷ 2 = 396 904 + 1;
- 396 904 ÷ 2 = 198 452 + 0;
- 198 452 ÷ 2 = 99 226 + 0;
- 99 226 ÷ 2 = 49 613 + 0;
- 49 613 ÷ 2 = 24 806 + 1;
- 24 806 ÷ 2 = 12 403 + 0;
- 12 403 ÷ 2 = 6 201 + 1;
- 6 201 ÷ 2 = 3 100 + 1;
- 3 100 ÷ 2 = 1 550 + 0;
- 1 550 ÷ 2 = 775 + 0;
- 775 ÷ 2 = 387 + 1;
- 387 ÷ 2 = 193 + 1;
- 193 ÷ 2 = 96 + 1;
- 96 ÷ 2 = 48 + 0;
- 48 ÷ 2 = 24 + 0;
- 24 ÷ 2 = 12 + 0;
- 12 ÷ 2 = 6 + 0;
- 6 ÷ 2 = 3 + 0;
- 3 ÷ 2 = 1 + 1;
- 1 ÷ 2 = 0 + 1;
3. Construct the base 2 representation of the positive number:
Take all the remainders starting from the bottom of the list constructed above.
106 543 246 315 365(10) = 110 0000 1110 0110 1000 1000 0101 1001 1000 1111 0110 0101(2)
4. Determine the signed binary number bit length:
The base 2 number's actual length, in bits: 47.
- A signed binary's bit length must be equal to a power of 2, as of:
- 21 = 2; 22 = 4; 23 = 8; 24 = 16; 25 = 32; 26 = 64; ...
- The first bit (the leftmost) is reserved for the sign:
- 0 = positive integer number, 1 = negative integer number
The least number that is:
1) a power of 2
2) and is larger than the actual length, 47,
3) so that the first bit (leftmost) could be zero
(we deal with a positive number at this moment)
=== is: 64.
5. Get the positive binary computer representation on 64 bits (8 Bytes):
If needed, add extra 0s in front (to the left) of the base 2 number, up to the required length, 64:
106 543 246 315 365(10) = 0000 0000 0000 0000 0110 0000 1110 0110 1000 1000 0101 1001 1000 1111 0110 0101
6. Get the negative integer number representation:
To get the negative integer number representation on 64 bits (8 Bytes),
... change the first bit (the leftmost), from 0 to 1...
-106 543 246 315 365(10) Base 10 integer number converted and written as a signed binary code (in base 2):
-106 543 246 315 365(10) = 1000 0000 0000 0000 0110 0000 1110 0110 1000 1000 0101 1001 1000 1111 0110 0101
Spaces were used to group digits: for binary, by 4, for decimal, by 3.