Computer Science 237 |
Lecture 21: Error Correcting Memory, Computation Circuits
Date: October 30, 2006
int mult_by_adding(int x, int y) { int product = 0; while (x > 0) { product += y; x--; } return product; }
int multiply(int x, int y) { int product = 0; while (x) { if (x&1) product+=y; x >>= 1; y <<= 1; } return product; }