16.02.26.md (1066B)
1 # 16/02/2026 2 3 ## Comparing integers 4 5 - for normal rep, all is normal, loop through all the bits 6 7 - for SM, check if the sign bit is set, if it is, then use normal 8 - if both sign bits are the same, then do normal, but return the opposite of the expected result 9 - if they have different signs, then use the sign bit to compare, and dont forget to check the double 0 10 11 - for 1's comp. you can use normal rep algo, if both sign bits are the same 12 - if the sign bits are different, you can use the sign bit to check which is larger 13 - don't forget the double 0 14 15 - for 2's comp. same as 1's comp. but no worry for the doube 0 16 17 - for excess, all is normal 18 19 ## Adding integers 20 21 - SM is shit when adding 22 23 - 1's comp. is slightly better, but not really 24 25 - 2's comp works when you have two pos, two diff or 2 neg 26 - you can't always detect overflow, as sometimes to overflow is valid 27 28 - excess is easy, just messy, add the bias to both, then do the addition, then subtract the bias from the result 29 - can be more efficient by only adding adding the bias to one of the numbers