Determining Sign of Binary Numbers & 4-Bit Subtracter

Click For Summary

Discussion Overview

The discussion revolves around how to determine the sign of binary numbers, particularly in the context of a 4-bit subtracter project. Participants explore various methods of representing negative numbers in binary, including two's complement, and the implications of these representations in hardware and software contexts.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • Some participants question how to identify if a binary number, such as 1111, represents a positive or negative value, specifically whether it is 15 or -1.
  • One participant suggests that the interpretation of the sign depends on how the circuit treats the number, mentioning the distinction between signed and unsigned operations in assembly language.
  • Another participant raises the importance of specifications for the 4-bit subtracter and questions whether displaying negative results with a sign is permissible.
  • A claim is made that the sign of a binary number is a conceptual choice made by the programmer, emphasizing the cyclic nature of binary counting and how it can represent both positive and negative values depending on the convention used.
  • It is noted that there are multiple methods for representing negative numbers, such as one's complement and two's complement, which can affect how digital signed numbers are processed.

Areas of Agreement / Disagreement

Participants express differing views on how to interpret the sign of binary numbers and the conventions used in binary representation. There is no consensus on a single method or approach, and multiple competing views remain regarding the treatment of signed and unsigned numbers.

Contextual Notes

The discussion highlights the dependence on specific circuit designs and programming conventions, as well as the potential for confusion arising from different representations of negative numbers. Limitations in understanding may stem from assumptions about hardware specifications and the context in which binary numbers are used.

kElect
Messages
20
Reaction score
0
how can you tell if a binary number is negative or positive?

1111 <--- how do you know if this is 15 or -1?

and for my project i have to make a 4 bit subtracter using LED lights to show 1's or 0's. Do I just leave it in 2's complement form?
 
Engineering news on Phys.org
hi there

that's an interesting Q and not one I cannot answer, haven't thought about that before
I will also be interested in seeing any response

in the mean time have a look at this www page and see if you can make sense of it ...
http://www.allaboutcircuits.com/vol_4/chpt_2/3.html

Dave
 
kElect said:
how can you tell if a binary number is negative or positive?

1111 <--- how do you know if this is 15 or -1?

and for my project i have to make a 4 bit subtracter using LED lights to show 1's or 0's. Do I just leave it in 2's complement form?

If you are able to do an operation like a multiply or divide and you can read the flags or generate an interrupt for an overflow error than that will tell you specifically if things are being treated as signed or unsigned implicitly.

The thing it will always depend on how the circuit treats the number. In an x86 type assembly environment we have IDIV and IMUL vs DIV and MUL for signed vs unsigned division and multiplication.

If you are using some circuit or device that is pre-made then I would just read the specifications and see how it treats the data to see if it uses signed numbers (MSB is sign) or unsigned (MSB is used to represent highest bit of actual data).

Usually if you have a circuit that has to do a specific operation like signed add or subtract, it will provide a flag of some sort (through an output pin) to say whether there was an error. In software it's done through either a flag or an interrupt but in hardware it will be given by an output pin. If the circuit or device has no error output of this kind then I would get a circuit or device that does if you are concerned about this.
 
kElect said:
how can you tell if a binary number is negative or positive?

1111 <--- how do you know if this is 15 or -1?

and for my project i have to make a 4 bit subtracter using LED lights to show 1's or 0's.
Have you been given the specs for your 4 bit subtractor? If so, what are they?
Do I just leave it in 2's complement form?
Are you allowed to display the answer with a negative sign prepended? That would be the most user friendly, I'd think.
 
I claim :

The sign of a binary number exists only in the mind of the programmer.

For any fixed number of bits the binary system is cyclic.
That is, it starts at zero where all bits are 0's and increments until all bits are 1's, meaning it's reached the largest number that can be represented with that many bits.
The next increment after all 1's flips it back to starting point, all 0's.

So - with N bits we can represent 2^N different values.
It is usually chosen to let half those values be negative and the other half be positive.
Further it is (i think) universally chosen to let all 0's represent zero.

Let us take a four bit counter for a simple example.
We'll start at zero, then increment the counter by one [STRIKE]seventeen[/STRIKE] sixteeen times, because 2^4 = sixteen and that's how many numbers we can represent with four bits.. [STRIKE]seven[/STRIKE] sixteenth increment should restart the count.
and we want to show the cyclic nature of binary counting.

0000 = zero
0001 = one
0010 = two
0011 = three
0100 = four
0101 = five
0110 = six
0111 = seven = largest positive number that can be represented with four bits IF you want luxury if signed numbers
1000 = -seven = largest negative number that can be represented with four bits IF you want luxury if signed numbers , or = +eight if you don't
1001 = -six = still counting up
1010 = -five
1011 = -four
1100 = -three
1101 = -two
1111 = -one if you want luxury of signed numbers, or = +fifteen if you don't
0000 = zero , still counting up, but the leading 1 disappeared off left end. (In a real machine thet'd be a carry bit but we are just studying nature of a 4-bit binary system here.)
0001 = one , and cycle starts again.

So you see that it is convenient but not necessary to use leftmost bit for sign.
We could as easily have used the four bits to count from zero to fifteen.

Count those increments to make sure i got [STRIKE]seventeen[/STRIKE] sixteen of them.

So to your question -

if the leftmost bit is set to 1 it is USUALLY a negative number because that's the convention.
But since you are building the machine the choice is really up to you.
When Mother Nature gave us the binary system she left it up to us how to use it.

And that's why chiro mentioned signed vs unsigned arithmetic.

Is that any help?

old jim
 
Last edited:

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
20K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 15 ·
Replies
15
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 12 ·
Replies
12
Views
11K
Replies
5
Views
2K
Replies
8
Views
2K