T
Ttodir
Hello,
I need a fast way to calculate (a * b) % B, with the following
constraints:
- a, b, B are int
- B = 10^N , N>0 arbitrary (B always fits in an int)
- the result must be valid even if the multiplication overflows
- portable code, no assumptions on the sizeof(int) and no types larger
than int can be used.
Any help will be much appreciated.
I need a fast way to calculate (a * b) % B, with the following
constraints:
- a, b, B are int
- B = 10^N , N>0 arbitrary (B always fits in an int)
- the result must be valid even if the multiplication overflows
- portable code, no assumptions on the sizeof(int) and no types larger
than int can be used.
Any help will be much appreciated.