Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is mostly equivalent to grade-school multiplication, but in binary. Good enough for multiplying small numbers; too slow for very big numbers.


Actually, this is basically how it is done in circuits, with some minor optimizations on top and without the explicit doubling operation.

It's about as simple as you can make a task like this. The grade school mechanism doesn't look so bad, when you consider that where multiplying by a digit 0-9 occasionally involves some carrying and non-trivial work but multiplying by a binary digit is a simple AND operation. The result is that with fixed operand size and no carrying, each digit you would write under the line using the grade school method can be determined directly as the AND of two bits of the input, and what's left is only a bunch of binary addition.

https://en.wikipedia.org/wiki/Binary_multiplier




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: