Signed-magnitude arithmetic
Signed addition
Before can before arithmetic with signed-magnitude, we must find and operate on the magnitude as if it was an unsigned binary number.
- If the signs are the same:
- Add magnitude to find resutling mangitude.
- Sign bit of result will stay the same.
- If they’re different:
- Subtract smaller magitude from larger magnitude.
- Use sign of operand with larger magntiude for result.
Signed subtraction
We can reduce the complexity of computing binary subtraction, such as in , by considering the second operand as a negative number in an addition, by this we can write it as . This is relatively cheap to do, as we only need to flip the sign bit, now we can perform signed-magnitude addition on the two resulting operands.
Signed multiplication / division
- Multiply or divide magnitudes as signed binary.
- Check whether both operands have the same sign:
- If they are the same: result has positive sign.
- If not: result has negative sign.