How to do a 32bit multiplication with 64bit result in C? :-)
If your compiler supports 64-bit long-longs, you're done. If not, you can do it with 16-bit "digits" much like you'd do it with decimal digits using pencil and paper.
you can do it with 16-bit "digits" much like you'd do it with decimal digits using pencil and paper. If it is the ARM (the op could not be bothered with selecting a toolset) then 32 bit "digits" will do nicely. If it is the '51 it is possible, but the calculation would take just about overnight. Erik
"... 32 bit "digits" will do nicely" If we're doing it like we'd do it by hand, 32-bit "digits" won't work because 32-bits times 32-bits would overflow. "16B" below represents a 16-bit "digit". 16-bits times 16-bits fits in a 32 integer.
16B,16B (32-bit multiplicand) * 16B,16B (32-bit multiplier) ------------------ + 16B,16B (32-bit partial product) + 16B,16B (32-bit partial product) + 16B,16B (32-bit partial product) + 16B,16B (32-bit partial product) ================== 16B,16B,16B,16B (64-bit product)