I am trying to understand what this decimal code would be as a binary:
I understand how to normally get the answer, because I would take 425 and then figure out that 256 + 128 + 32 + 8 + 1 = 425, which would be 110101001 in binary.
However, I am completely thrown off by the d in the decimal. How can I understand what it is and how to solve this (if the answer is different than 110101001)?
Related
I am having some difficulty understanding why this recursive algorithm works mathematically for converting decimal to binary.
I understand that the last digit in binary code determines if the decimal number is odd or even, thus we can use the remainder(%) to determine if the last digit is 0(odd) or 1(even). However, my thought process stops there, and I am confused about why the digit in position for 2 to the higher power can be calculated by dividing the decimal by 2 and then check its %2 as shown in the picture.
Can someone help me understand the logic behind the conversion? Thank you very much!
This is the way to calculate a number in accord to a base, you can do it for every base b>1. for example the same number should be expressed in base b = 3
Start Conversion from base 10 to base 3
26/3 = 8 + 2
8/3 = 2 + 2
(26)_10 = (222)_3
Proof
2*3^2 + 2*3 + 2*1 = 18+6+2 = 26
Question on an assignment:
How to express -20 (in decimal) as fixed point notation, 8 bits, 2's complement.?
Answer:
EC(16 ---> in hexadecimal.
Question:
I understand how to get that answer. I convert the -20 in base 10 to 2's complement and you get 11101100. 1110=E in hexadecimal and 1100=C in hexadecimal.
What is confusing me, however, is that EC(16 is equal to 236 in decimal. How can EC(16 equal both -20 and 236 in decimal??!
I am confused as to how that works?
As Juan wrote: It just depends on how the bits are interpreted. More specifically, in your case it depends only on how the most significant bit is interpreted. The lower seven bits in both cases add up to 22 + 23 + 25 + 26 = 4 + 8 + 32 + 64 = 108. Now, the highest bit if used as an ordinary value bit has the value 27 = 128 and thus makes 108 + 128 = 236, while if used as the sign bit it has the value −27 = −128 and thus makes 108 − 128 = −20.
I'm studying in French, so I'll try to translate the terms as best as I can, so sorry if it may be unclear.
I have to find the coded message (CRC) with this 10 bits message : 0011111111 and x^2 + x as the polynomial divisor.
I don't have much knowledge in binary and CRC yet, but I still know how to calculate one, but this one is a bit more tricky for me since the polynomial divisor is not an usual one.
There are a lot of examples with divisors such as x^5 + x^4 + 1, but I have yet to find an example with something that resemble this one (x^2 + x).
Here's what I did, but I'm pretty sure that it isn't right at all
001111111100 | 110
110
00111
110
00111
110
00110
110
0000
Do you guys have any idea what I'm doing wrong here?
Thanks a lot!
You can try this :
Computation of CRC with 110 on 0011111111, and see that the result is 2, with a good explanation step by step.
I am trying to add the following two binary numbers together, however I am unable to do so becuase im not sure whether or not this is an overflow?
110101 + 010111
The answer I get is: 1001100
Do I remove the left most 1 in the answer or do I keep it? By removing it I get 12, otherwise the answer is Not right. Am I doing something wrong?
Is this right?
The answer to this question depends upon the size of the word in bits of the system you are talking about. In an 8-bit (or higher) system, and you're doing 2's complement, the sum of
110101 + 010111 = 1001100
Is the same as:
00110101 + 00010111 = 01001100
Is: 53 + 23 = 76 with no overflow or carry out.
If it's a 7-bit system, doing 2's complement, then you have:
0110101 + 0010111 = 1001100
Which is 53 + 23 = -52. There's an overflow, but no carry out.
If it's a 6-bit system, doing 2's complement, then:
110101 + 010111 = (1)001100
Which is -11 + 23 = 12. There's no overflow but there's a carry out. Note that in a 6-bit system you can't have 1001100 technically because it's 7 bits. You would have 001100.
For reference, see The CARRY flag and OVERFLOW flag in binary arithmetic.
I was playing around with 2's complement and found a quicker way of finding the value of a negative binary. Please help me prove this(right or wrong) or why it works! Thanks in advance!
2's complement is very useful for finding the value of a binary, however I thought of a much more concise way of solving such a problem(never seen anyone else publish it):
take a binary, for example: 1101 which is [assuming that space "1" is the sign] equal to -3.
using 2's complement we would do this...flip 1101 to 0010...add 0001 + 0010 ===> gives us 0011. 0011 in positive binary = 3. therefore 1101 = -3!
What I realized:
instead of all the flipping and adding, you can just do the basic method for solving for a positive binary(lets say 0101) is (23 * 0) + (22 * 1) + (21 * 0) + (20 * 1) = 5.
Do exactly the same concept with a negative!(with a small twist)
take 1101, for example:
for the first number instead of 23 * 1 = 8 , do -(23 * 1) = -8.
then continue as usual, doing -8 + (22 * 1) + (21 * 0) + (20 * 1) = -3
Note: this seemed to work for every test I did.
Thanks for looking. Also, if you haven't seen this before please let me know, I never seen this anywhere.
This solution seems to work for the tests which I did! Thanks for the quick solution to 2's complement, I will still test out some more difficult questions.