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?
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top