Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 12 34 56
- 78
- -- -- --
- 12 35 34
- 10
- 11-
- -- -- -- --
- 99 99 99 99 (and you still have a borrow).
- 11
- 10-
- --
- 1 (then negate to get -1).
- -a + b becomes b - a
- a + -b becomes a - b
- a - -b becomes a + b
- -a - b becomes -(a + b)
- small - big becomes -(big - small)
- 475(a) x 32(b) = 475 x (30 + 2)
- = 475 x 30 + 475 x 2
- = 4750 x 3 + 475 x 2
- = 4750 + 4750 + 4750 + 475 + 475
- 457
- +-------
- 27 | 12345 27 is larger than 1 or 12 so we first use 123.
- 108 27 goes into 123 4 times, 4 x 27 = 108, 123 - 108 = 15.
- ---
- 154 Bring down 4.
- 135 27 goes into 154 5 times, 5 x 27 = 135, 154 - 135 = 19.
- ---
- 195 Bring down 5.
- 189 27 goes into 195 7 times, 7 x 27 = 189, 195 - 189 = 6.
- ---
- 6 Nothing more to bring down, so stop.
- 457 x 27 + 6
- = 12339 + 6
- = 12345
- 123
- x 34
- -----
- 492
- + 3690
- ---------
- 4182
- unsigned char first[1024], second[1024], result[1025];
- unsigned char carry = 0;
- unsigned int sum = 0;
- for(size_t i = 0; i < 1024; i++)
- {
- sum = first[i] + second[i] + carry;
- carry = sum - 255;
- }
- 9
- +
- 9
- ----
- 18
Add Comment
Please, Sign In to add comment