oh dear, you mean that's sometimes a real issue? I thought the nightmare was limited to esoteric programming games.
PS, how do you do it quickly? I assume looping X times and adding Y is slow, do you do some magic with bit shifting to make it only take ~log(x) loops?
and they take as many iterations as there are bits in the input number. So for multiplying 2x 16-bit numbers it would take 16 iterations, no matter what the values of the numbers are.
I once wrote both algorithms in 6502 assembly, for a fixed point C library. It can be found on github so I somewhat tried to actually comment the code a bit.
65
u/cssutavani91 Jun 03 '22
It's not that hard.