You would determine if the remainder
is below an acceptable tolerance to your problem or if the remainder
is very close to your multipleOf
:
if (Math.Abs(remainder) < tolerance)
{
//remainder is negligible so we'll say it's a multiple
}
else if (Math.Abs(multipleOf) - Math.Abs(remainder) < tolerance)
{
//remainder is almost multiple of divisor so we'll say it's a multiple
}
Only you can decide on a small enough value for tolerance. Sometimes machine epsilon is used for this type of check but it might be too low. If v
is very large and multipleOf
very small we might say the problem is ill conditioned because the tolerance might need to be so high the results would be useless for the level of accuracy you require in your application. So searching for Conditioning and Precision might be of further interest as well.