Computer Composition Judgment Overflow

1. Concept

Overflow: The result of the operation exceeds the representation range of the machine number

2. Methods

1. Symbolic judgment of calculation results

If two numbers with the same sign are added, the result will overflow.

2. The carry bit c1 of the highest bit of the value and the carry bit c0 of the sign bit

If the carry bit c1 of the most significant bit of the value is different from the carry bit c0 of the sign bit, it overflows.

3. Double sign bit

Use the double sign bit:

Positive number 00

negative 11

If the two sign bits of the operation result are the same, there is no overflow.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325085248&siteId=291194637