![]() |
IET | ![]() |
|
search :
help :
home
|
||
|
Latest News:
|
|
|


|
Topic Title: Overflow and carry of binary numbers? Topic Summary: Created On: 21 July 2010 10:33 AM Status: Post and Reply |
Linear : Threading : Single : Branch |
Search Topic |
Topic Tools
|
|
|
|
|
Can I say that for overflow, the difference is the sign while for carry,the difference is in the magnitude. Otherwise, do you mind clarify with examples if possible. Thanks a lot.
|
|
|
|
|
|
|
|
|
I think you need to elaborate on the question. Are you adding or multiplying, or something else? Are the numbers signed or unsigned? If they are signed, is it 1's complement or 2's complement?
------------------------- S P Barker BSc PhD MIET |
|
|
|
|
|
|
|
|
If it's pure microprocessor accumulator operation then I believe (been 20 years) an overflow is where the accumulator has "overflowed" the size. The uP overflow flag would be set. This would be where an 8bit accumulator has gone from
11111111 to 00000000 as it would in this case: 11111111 00000001+ -------------- 00000000 overflow flag set You would not get an overflow on the following: 00000001 00000001+ -------------- 00000010 overflow flag not set In the case of a logical operation the overflow flag is not set. 11111111 10000001 and -------------- 10000001 overflow flag not set Thus when using "unsigned" values you care about the overflow. In the case of signed and unsigned values the uP knows nothing about them. The string of bits in the accumulator can be used to represent different series of values though Take: 01111111 00000001 + -------------- 10000000 overflow flag not set This is effectively saying that +127 + 1 = -128. Hmm overflow not set no error? But the MSB altered state! ERROR! 11111111 00000001+ -------------- 00000000 overflow flag set Overflow error? No because the MSB altered state!!! So for every "signed" arithmetic operation for need to check the MSB to see if it flips without an overflow, and flips with an overflow. As you "care" about the state of the overflow for both "unsigned" and "signed" values, you cannot say Originally posted by: Jasper12 However it is perfectly true to say that on the overflow flag being set and when using the accumulator to represent signed values this may not be an error condition. ------------------------- Ian Lowson MIET Do or do not, there is no try! Edited: 13 August 2010 at 08:48 AM by lowson_i |
|
|
|
|
|
IET
» Information technology
»
Overflow and carry of binary numbers?
|
Topic Tools |
FuseTalk Standard Edition v3.2 - © 1999-2013 FuseTalk Inc. All rights reserved.