Convert Decimals to Signed 12-Bit Numbers

  • MHB
  • Thread starter shamieh
  • Start date
  • Tags
    Numbers
In summary, to convert decimal numbers into signed 12 bit numbers in sign and magnitude, 1's complement, and 2's complement representations, you must first determine the sign (positive or negative) and then find the binary representation of the absolute value of the number. For positive numbers, this is done by finding the largest power of 2 that fits into the number and subtracting it, repeating until the remainder is 0. For negative numbers, the absolute value is found and then inverted using the 1's complement or 2's complement method.
  • #1
shamieh
539
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 \(\displaystyle 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? \(\displaystyle 2^{11} + 2^{10} + 2^9\) does NOT equal 1906!
 
Technology news on Phys.org
  • #2
shamieh said:
1906 sign and mag: 011101110010 , 1s comp = 011101110010 2s comp = 011101110010

but how? \(\displaystyle 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:
\(\displaystyle 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.
 
  • #3
shamieh said:
1906 sign and mag: 011101110010 , 1s comp = 011101110010 2s comp = 011101110010

but how? \(\displaystyle 2^{11} + 2^{10} + 2^9\) does NOT equal 1906!
How did you come up with \(\displaystyle 2^{11} + 2^{10} + 2^9\) starting from 011101110010?
 

FAQ: Convert Decimals to Signed 12-Bit Numbers

What is the purpose of converting decimals to signed 12-bit numbers?

Converting decimals to signed 12-bit numbers allows data to be represented in a more compact and efficient manner, making it easier to store and process in computer systems.

How do you convert a decimal number to a signed 12-bit number?

To convert a decimal number to a signed 12-bit number, you first need to determine the range of numbers that can be represented in 12 bits (from -2048 to 2047). Then, you can use a formula or conversion chart to map the decimal number to its corresponding 12-bit binary representation.

What is the difference between a signed and unsigned 12-bit number?

A signed 12-bit number can represent both positive and negative values, while an unsigned 12-bit number can only represent positive values. The first bit in a signed 12-bit number is used to indicate the sign (0 for positive, 1 for negative), while all 12 bits are used to represent the magnitude in an unsigned 12-bit number.

Can decimal numbers with decimal places be converted to signed 12-bit numbers?

Yes, decimal numbers with decimal places can be converted to signed 12-bit numbers. The decimal portion of the number can be converted to its binary representation and added to the 12-bit binary representation of the whole number, using the decimal point as a separator.

Are there any limitations to converting decimals to signed 12-bit numbers?

Yes, there are limitations to converting decimals to signed 12-bit numbers. The range of numbers that can be represented in 12 bits is limited, so very large or very small decimal numbers may not be able to be accurately represented. Additionally, converting decimals to signed 12-bit numbers may result in loss of precision, as the decimal places may need to be rounded or truncated to fit within the 12 bits.

Back
Top