I would like to find out whether one real number is a multitude of the other one. I'm using BC-Math because the code is part of a larger system doing price calculations and using floats results in wrong results on multiple calculations due to the behaviour of floating point math.
BC-Math has bcmod()
to get the modulus of an arbitrary precision number. However, before PHP 7.2 this function does not work with non-integer numeric strings. E.g:
echo bcmod('10', '9.2'); // 1, because '9.2' is truncated to '9'
Converting the numbers back to floats and using fmod()
isn't an option since fmod function returning wrong result
I couldn't find any solution to this problem but I can't image that there is no solution.
EDIT:
Hello reader in the future who encounters the same problem! Based on @chiliNUT's response I created a pull-request for the bcmath-extended library.