commit c9956debe97627b0adc12ee34e95d3bc4b0884fa
parent 03a166d2a1fc9f28909693c12143f9079ffccf10
Author: glenda <glenda@cirno>
Date: Mon, 16 Feb 2026 15:53:42 +0000
notes on adding
Diffstat:
1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/CS10720/16.02.26.md b/CS10720/16.02.26.md
@@ -1,15 +1,29 @@
# 16/02/2026
-## comparing integers
+## Comparing integers
- for normal rep, all is normal, loop through all the bits
- for SM, check if the sign bit is set, if it is, then use normal
-- if both sign bits are the same, then do normal, but return the opposite of the expected result
-- if they have different signs, then use the sign bit to compare, and dont forget to check the double 0
+ - if both sign bits are the same, then do normal, but return the opposite of the expected result
+ - if they have different signs, then use the sign bit to compare, and dont forget to check the double 0
- for 1's comp. you can use normal rep algo, if both sign bits are the same
-- if the sign bits are different, you can use the sign bit to check which is larger
-- don't forget the double 0
+ - if the sign bits are different, you can use the sign bit to check which is larger
+ - don't forget the double 0
- for 2's comp. same as 1's comp. but no worry for the doube 0
+
+- for excess, all is normal
+
+## Adding integers
+
+- SM is shit when adding
+
+- 1's comp. is slightly better, but not really
+
+- 2's comp works when you have two pos, two diff or 2 neg
+ - you can't always detect overflow, as sometimes to overflow is valid
+
+- excess is easy, just messy, add the bias to both, then do the addition, then subtract the bias from the result
+ - can be more efficient by only adding adding the bias to one of the numbers