Convert Numbers to 12-Bit Binary Using 2's Complement

In summary, the conversation discusses converting numbers to 12-bit binary using two's complement representation. The correct conversion for 234 is to simply convert it to binary, while for -234, the steps include converting to binary, complementing, adding 1, complementing again, and then adding 1. The conversation also mentions checking the correctness of the conversion by adding the original number with its two's complement. Additionally, it is mentioned that for positive numbers, no conversion is necessary, and for negative numbers, the MSB can determine whether the number is negative in two's or one's complement.
  • #1
fsm
88
0

Homework Statement


Covert the following numbers to 12-bit binary numbers using two's complement representation.

234
-234

Homework Equations


None I know of.


The Attempt at a Solution


I think I'm making this more complicated than it really is. For 234 I can just convert right to binary or do I have to convert 234 to binary, complement, add 1, complement, and then add 1?

For -234:
000011101010
111100010101
1(adding 1 to LSB)
111100010110

On a side note converting a negative number to octal or hex say -234. You convert it like any other binary number? When converting back how do you know you have a negative number or positive number? By the MSB?
 
Physics news on Phys.org
  • #2
You did the conversion correctly. The way you can check is to add 234 with -234. The result should be 0 (within the 12 bits).

For positive numbers, you need do nothing. 234 is the same in two's complement, the same in one's complement, the same in unsigned. The conversion method is used to convert positive to negative and negative back to positive.

If the MSB is 1, then yes, that number is negative in two's or one's complement.
 
  • #3
Thanks!
 

1. How do you convert a decimal number to 12-bit binary using 2's complement?

To convert a decimal number to 12-bit binary using 2's complement, follow these steps:

  • Step 1: Determine the sign of the decimal number (positive or negative).
  • Step 2: Convert the absolute value of the number to binary using the standard binary conversion method.
  • Step 3: If the number is positive, simply add 0's to the left of the binary representation until it is 12 bits long.
  • Step 4: If the number is negative, take the 2's complement of the binary representation by flipping all the bits and adding 1 to the result.
  • Step 5: Add 1's to the left of the resulting binary representation until it is 12 bits long.

2. What is the purpose of using 2's complement in converting numbers to 12-bit binary?

The 2's complement method is used in binary conversion to represent negative numbers in a binary system. It simplifies arithmetic operations and allows for a more efficient use of memory space.

3. Can you give an example of converting a negative decimal number to 12-bit binary using 2's complement?

Of course. Let's convert -7 to 12-bit binary using 2's complement:

  • Step 1: Determine the sign -7 is a negative number.
  • Step 2: Convert the absolute value of 7 to binary: 111.
  • Step 3: Take the 2's complement by flipping all the bits and adding 1: 000 + 1 = 001.
  • Step 4: Add 1's to the left until it is 12 bits long: 111111111001.
Therefore, -7 in 12-bit binary using 2's complement is 111111111001.

4. How do you convert a 12-bit binary number back to decimal using 2's complement?

To convert a 12-bit binary number back to decimal using 2's complement, follow these steps:

  • Step 1: Determine the sign of the binary number (positive or negative).
  • Step 2: If the number is positive, simply convert it to decimal using the standard binary to decimal conversion method.
  • Step 3: If the number is negative, take the 2's complement of the binary number by flipping all the bits and adding 1 to the result.
  • Step 4: Convert the resulting binary number to decimal using the standard binary to decimal conversion method.
  • Step 5: Add a negative sign to the decimal result.

5. What is the maximum and minimum value that can be represented in 12-bit binary using 2's complement?

In 12-bit binary using 2's complement, the maximum value that can be represented is 011111111111 which is equivalent to +2047 in decimal. The minimum value that can be represented is 100000000000 which is equivalent to -2048 in decimal.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
5
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
622
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
13
Views
3K
Replies
4
Views
905
  • Engineering and Comp Sci Homework Help
Replies
10
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
Back
Top