Guest User

Untitled

a guest
May 20th, 2018
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. 12 34 56
  2. 78
  3. -- -- --
  4. 12 35 34
  5.  
  6. 10
  7. 11-
  8. -- -- -- --
  9. 99 99 99 99 (and you still have a borrow).
  10.  
  11. 11
  12. 10-
  13. --
  14. 1 (then negate to get -1).
  15.  
  16. -a + b becomes b - a
  17. a + -b becomes a - b
  18.  
  19. a - -b becomes a + b
  20. -a - b becomes -(a + b)
  21.  
  22. small - big becomes -(big - small)
  23.  
  24. 475(a) x 32(b) = 475 x (30 + 2)
  25. = 475 x 30 + 475 x 2
  26. = 4750 x 3 + 475 x 2
  27. = 4750 + 4750 + 4750 + 475 + 475
  28.  
  29. 457
  30. +-------
  31. 27 | 12345 27 is larger than 1 or 12 so we first use 123.
  32. 108 27 goes into 123 4 times, 4 x 27 = 108, 123 - 108 = 15.
  33. ---
  34. 154 Bring down 4.
  35. 135 27 goes into 154 5 times, 5 x 27 = 135, 154 - 135 = 19.
  36. ---
  37. 195 Bring down 5.
  38. 189 27 goes into 195 7 times, 7 x 27 = 189, 195 - 189 = 6.
  39. ---
  40. 6 Nothing more to bring down, so stop.
  41.  
  42. 457 x 27 + 6
  43. = 12339 + 6
  44. = 12345
  45.  
  46. 123
  47. x 34
  48. -----
  49. 492
  50. + 3690
  51. ---------
  52. 4182
  53.  
  54. unsigned char first[1024], second[1024], result[1025];
  55. unsigned char carry = 0;
  56. unsigned int sum = 0;
  57.  
  58. for(size_t i = 0; i < 1024; i++)
  59. {
  60. sum = first[i] + second[i] + carry;
  61. carry = sum - 255;
  62. }
  63.  
  64. 9
  65. +
  66. 9
  67. ----
  68. 18
Add Comment
Please, Sign In to add comment