Quick Sign Magnitude Negation question.

Ok ive learned negation in Sign magnitude but I hit a bump in the road with one problem that seems to make the basic rules not work. So if someone would be so kind as to tell me how you subtract this sign magnitude problem out I would be very thankful.

01100100 (Which is 100) minus

00111100 (Which is 60) Seems very simple and I know all you have to do is

subtract but how do you subtract from 0? Where the 0's are above the 1's. In basic arithmetic that would be negative 1 but not in Sign magnitude. Anyone see what im saying?

[557 byte] By [venturea] at [2007-11-26 16:30:38]
# 1
011001001000011110060--0010100040Does that help at all?
CaptainMorgan08a at 2007-7-8 22:55:04 > top of Java-index,Java Essentials,Java Programming...
# 2

I can get that simply by saying 100 minus 60 equals 40 and then converting 40 into Sign Magnitude. What im trying to figure out is how do you actually work that out. The part in question is the 2 zero's above the 2 ones that are bolded. If you actually subtract that that would be negative 1. So obviously this is binary so we cant bring negative ones down what do we do? Thanks for the reply BTW, and I hope Im not insulting anyones intelligience im just trying to make it clear what im confused about.

01100100100

0011110060

--

0010100040

Message was edited by:

venture

venturea at 2007-7-8 22:55:04 > top of Java-index,Java Essentials,Java Programming...
# 3
How would you subtract this:21121221-?Do it by hand, then see if you can apply it to the binary problem.
CaptainMorgan08a at 2007-7-8 22:55:04 > top of Java-index,Java Essentials,Java Programming...
# 4

first make two's complement of 00111100.

1's complement is 11000011

add 1 to make 2's complement

11000011

+1

11000100

now add this two's complement in original one 01100100.

01100100

+ 11000100

__

1 00101000 ( answer)

Now check the sign bit

here00101000

first is sign bit and it is 0

Here Sign bit is 0 means positive no. so answer is

00101000

Message was edited by:

pareshppatel

pareshppatela at 2007-7-8 22:55:04 > top of Java-index,Java Essentials,Java Programming...
# 5

Another way is called 2s complement addition. If you want to subtract 60 from 100 then you can add minus 60 to 100. In 2s complement the high order bit is the sign bit. To represent minus 60 in 2s complement binary notation you first write +60 in binary, then form the 1s complement (by inverting all the bits), and then add 1.

So,

0 0 1 1 1 1 0 0= 60

1 1 0 0 0 0 1 1= 1s complement. (-128 sign bit, + 64 + 2 + 1) = -61

1+ 1 to form the 2s complement

1 1 0 0 0 1 0 0= 2s complement (-128 + 64 + 4) = -60

So, add minus 60 to 100, which is the same as 100 - 60.

0 1 1 0 0 1 0 0=100

1 1 0 0 0 1 0 0= -60

0 0 1 0 1 0 0 0= 40

Notice that the carry from the left most column is ignored, because we are using 8 bit binary 2s complement addition. Also the sign bit in the answer is cleared, so the answer is positive.

codebytesa at 2007-7-8 22:55:04 > top of Java-index,Java Essentials,Java Programming...
# 6
Not sure why or how (who) deleted the solution to this problem but here it is again. Hopefully it will stay this time. http://mathforum.org/library/drmath/view/55733.html
venturea at 2007-7-8 22:55:04 > top of Java-index,Java Essentials,Java Programming...
# 7

> Not sure why or how (who) deleted the solution to

> this problem...

I expect it's the special Random Mods?that we have here, who normally do nothing, allowing the forums to be overrun by trolls, then go on pruning sprees, removing this and that without regard for, well, anything really.

Mr_Evila at 2007-7-8 22:55:04 > top of Java-index,Java Essentials,Java Programming...