binary arithmatic problem


Recommended Posts

hi, i'm new here, hope this post is in the right place.

Anyway, just wanna ask a silly question:

what are the results of the two operationz on UNSIGNED numbers, noting nay overflow conditions?

1) 1010 + 1100

2) 1010 - 1100

Plz give some explanations, cheers.

Link to comment
Share on other sites

I haven't toched this in a year and I forget things but...

1010

+1100

=[1]0110

A flag would be set for overflow.

1010

- 1100

I can't remember subtraction...

Link to comment
Share on other sites

I haven't toched this in a year and I forget things but...

1010

+1100

=[1]0110

A flag would be set for overflow.

1010

- 1100

I can't remember subtraction...

addition should be easy when u indicate the overflow,

don't know the solution to subtraction.

thx anyway.

Link to comment
Share on other sites

Binary subtraction is just like decimal subtraction.... but different... :rofl:

01

-01

===

00

10

-01

===

01

When you subtract binary, and you have a 1-0 situation, subtract 1 from the binary digit to the left, and make the 0 a 2.

[btw, in your example 2, since you are subtracting a larger number from a smaller one (and the numbers are unsigned), then you get an underflow condition]

Link to comment
Share on other sites

1010

- 1100

----------

? 0010

I think, but don't know how to deal with the top bit. seems used to indicate sign or what?

cuz 1010 in decimal is 10, and 1100 in decimal is 12, if by decimal operation, the result should

be -2, which is - 0010.

not sure about that. I mean do I have to do this with UNSIGNED binary numbers?

Link to comment
Share on other sites

Binary subtraction is just like decimal subtraction.... but different... :rofl:

01

-01

===

00

10

-01

===

01

When you subtract binary, and you have a 1-0 situation, subtract 1 from the binary digit to the left, and make the 0 a 2.

[btw, in your example 2, since you are subtracting a larger number from a smaller one (and the numbers are unsigned), then you get an underflow condition]

so what's the answer to it?

Link to comment
Share on other sites

1010 - 1100

10 - 12 = -2

= 1110

or

= -0010

depends how u represent a negative binary number

1110, that's in 2's complements, but the problem is what "kind" of answer should I give to that specific question which required as UNSIGNED numbers?

thx.

Link to comment
Share on other sites

not using any signed representation like sign & magnitude, 1's complement, 2's complement etc.

You can also think of it as a normal "byte". It is (typically) unsigned, therefore, it has the range of:

00000000 = 0

to

11111111 = 255

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.