How do I convert signed decimal to binary

  • Thread starter Thread starter XodoX
  • Start date Start date
  • Tags Tags
    Binary Convert
Click For Summary

Discussion Overview

The discussion revolves around converting signed decimal numbers to 32-bit two's complement binary representations. Participants explore the methodology for this conversion, including the steps involved and the reasoning behind them.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Homework-related

Main Points Raised

  • One participant suggests converting the positive value first and then flipping the bits, but expresses confusion about the process.
  • Another participant proposes counting backwards from binary representations of positive numbers to derive negative values, referencing a Wikipedia article for clarification.
  • A later reply outlines a step-by-step method for conversion, including flipping bits and adding one, while also discussing the significance of the addition step in the context of zero.
  • Participants express uncertainty about the correctness of their understanding and the examples provided, with some noting discrepancies in the methods described.
  • One participant attempts to clarify the process using a fabricated example to illustrate the conversion of a binary number to its two's complement representation.

Areas of Agreement / Disagreement

Participants generally express confusion and uncertainty regarding the conversion process, with no consensus on a single correct method. Multiple viewpoints and approaches are presented, indicating that the discussion remains unresolved.

Contextual Notes

Some participants mention reading external resources, such as Wikipedia, but still find the explanations unclear. There are indications of missing assumptions or misunderstandings about the two's complement system and its application.

XodoX
Messages
195
Reaction score
0
1. Convert the following numbers to 32-bit two's complement binary numbers.

-22 , -100





Can someone explain this to me? I thought I just convert the +22, which is 10110 and add it to all the 1's. Like,

111111...10110 and positive would be 00000000...10110. But that's not how it works.
 
Physics news on Phys.org
XodoX said:
1. Convert the following numbers to 32-bit two's complement binary numbers.

-22 , -100





Can someone explain this to me? I thought I just convert the +22, which is 10110 and add it to all the 1's. Like,

111111...10110 and positive would be 00000000...10110. But that's not how it works.

You need to count backwards from 0000000 to 1111111 to 1111110, etc. Count with 0's for the negative numbers, not with 1's:

http://en.wikipedia.org/wiki/2s_complement

.
 
I don't knwo what you mean. I don't even shave the right numbers it seem.s
 
XodoX said:
I don't knwo what you mean. I don't even shave the right numbers it seem.s

Did you read the wiki link?
 
Yeah, I don't get it. I read it before I posted this thread.
 
Right, here's how it's done.

1) You were right to convert the +ve value to binary to give 000...010110
2) Flip the bits (every 1 becomes a 0)
3) add 1 to the answer.

The bit that intrigued me was the adding 1 part but if we take 0 as an example and use 8 bits then:

0(dec) = 00000000(bin)
flip to give 11111111(dec)
If you don't add 1 then +0 and -0 are different so we add 1 and discard the carry to give 00000000.

-1 would then be 11111111
-2 becomes 11111110 and so on.

To show the usefulness of this let's have a look at 5 - 2:

We treat it as 5 + (-2) as you can in decimal:

00000101
11111110 +
-----------
00000011 (overfow set but ignored here)

So there you go, a whistlestop tour of 2's complement!
 
Thank you. So,

0110 1100 0001 0000 would be

0110 1100 0001 0001

I just haver seen an example where they did it totally differently.
 
Not quite, to save any issues on here (and make sure I'm not doing any homework) I'll use an example I'm making up:

0011 0110 1001 0011
1100 1001 0110 1100 - Flipped
1100 1001 0110 1101 - With the 1 added, and that's the -ve value of 0011 0110 1001 0011 using 2's complement.
 
Last edited:

Similar threads

  • · Replies 2 ·
Replies
2
Views
5K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
6K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
5
Views
2K
Replies
4
Views
2K