4 ms·
"...the two numbers being multiplied are not the same length." Do you mean as counted in bits? If so, prepend zeroes until they are the same length. Does this
by delinka 8y ago
"...the two numbers being multiplied are not the same length."
Do you mean as counted in bits? If so, prepend zeroes until they are the same length. Does this negatively affect the algorithm's results?
EDIT: When I say 'prepend' I mean on the MSB end. In typical arithmetic on paper, that'd be adding leading zeroes (prepending) onto the numbers.
- taejo 8y agoYou can do that - it's the "textbook" solution - but you can probably do better by not making your inputs larger: in the worst case you're going from multiplying N digits by 1 digit to N digits by N digits.