This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Integer overflow

Hello to everyone.

When I have to calculate the average of two integer numbers, first i have to add them. Sometimes an overflow occurs. One technique maybe to compare the result to one of the numbers, if result is lower, an overflow is recognized.

Is this good style or better use Assembler?

Parents
  • Is this good style or better use Assembler?

    In Assembly, the Carry flag signals if there was an overflow during an addition. There is no need to do any comparison.

    Now, if you were to do the same in C, then yes, you would need to compare a number and the result.

Reply
  • Is this good style or better use Assembler?

    In Assembly, the Carry flag signals if there was an overflow during an addition. There is no need to do any comparison.

    Now, if you were to do the same in C, then yes, you would need to compare a number and the result.

Children
No data