Saturday, 18 February 2017

modular arithmetic - Multiplication of floating numbers to a modulus

As we all know, the integers follow the following identity :



$$(A\cdot B\cdot C) \bmod M = ((A\cdot B) \bmod M\cdot C) \bmod M$$



But it does not work for real numbers having fractional part. For example:




$$1.7\cdot 1.7\cdot 1.7 = 0.913 \bmod 2.0$$



whereas,



$$1.7\cdot 1.7 = 0.89 \bmod 2.0$$



and, $0.89\cdot 1.7 = 1.513 \bmod 2.0$



We see the two results are unequal. So, does the modular identities do not work with real numbers? If yes, is there any way I could do multiplication of real numbers to get the expected result?

No comments:

Post a Comment