MHB Convert Decimals to Signed 12-Bit Numbers

  • Thread starter Thread starter shamieh
  • Start date Start date
  • Tags Tags
    Numbers
AI Thread Summary
The discussion focuses on converting decimal numbers 73, 1906, -95, and -1630 into signed 12-bit representations using sign and magnitude, 1's complement, and 2's complement formats. For the positive number 73, all three representations are the same: 000001001001. The conversion for 1906 is more complex, with the correct binary representation being 011101110010 for all three formats. The confusion arises from the calculation of powers of 2; the correct breakdown shows that 1906 can be represented by summing the powers of 2: 2^10 (1024), 2^9 (512), 2^8 (256), 2^6 (64), 2^5 (32), 2^4 (16), and 2^1 (2). The discussion emphasizes the importance of accurately identifying the largest powers of 2 that fit into the number during conversion.
shamieh
Messages
538
Reaction score
0
Convert the decimal numbers 73, 1906, -95, and -1630 into signed 12 bit numbers in the following representations:
a) Sign and magnitude
b) 1's complement
c) 2's complement

So 73 is easy. It's positive so I know it starts with 0. so I know that

73: sign and mag = 000001001001, 1s complement = 000001001001, 2's complement = 000001001001 . We know this because $$2^6 + 2^3 + 2^0 = 73.$$

BUT let's say I have

1906. I know the first digit will be 0 because it is positive.

So wouldn't I find the sign and magnitude the same way?

1906 sign and mag =what? Apparently it doesn't work the same way?

they are getting this:

1906 sign and mag: 011101110010 , 1s comp = 011101110010 2s comp = 011101110010

but how? $$2^{11} + 2^{10} + 2^9$$ does NOT equal 1906!
 
Technology news on Phys.org
shamieh said:
1906 sign and mag: 011101110010 , 1s comp = 011101110010 2s comp = 011101110010

but how? $$2^{11} + 2^{10} + 2^9$$ does NOT equal 1906!

Counting from right to left, the 1's in your number correspond to the powers of 2:
$$2^{10} + 2^9 + 2^8+ 2^6 + 2^5 + 2^4 + 2^1=1906$$

To convert 1906 to a binary number you would find the largest power of 2 that fits into it, yielding the first '1'.
Then subtract it and repeat.

The largest power of 2 that fits is $2^{10}=1024$.
That leaves $1906 - 1024 = 882$.
Next largest power of 2 that fits is $2^9=512$.
Leaving $882 - 512 = 370$.
And so on.
 
shamieh said:
1906 sign and mag: 011101110010 , 1s comp = 011101110010 2s comp = 011101110010

but how? $$2^{11} + 2^{10} + 2^9$$ does NOT equal 1906!
How did you come up with $$2^{11} + 2^{10} + 2^9$$ starting from 011101110010?
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
Thread 'Project Documentation'
Trying to package up a small bank account manager project that I have been tempering on for a while. One that is certainly worth something to me. Although I have created methods to whip up quick documents with all fields and properties. I would like something better to reference in order to express the mechanical functions. It is unclear to me about any standardized format for code documentation that exists. I have tried object orientated diagrams with shapes to try and express the...
Back
Top