I need to determine if some number is divisible by some other number. A simple solution is:
public boolean isDivisibleBy(double dividend, double divisor)
{
return dividend % divisor == 0;
}
Unfortunately this does not work if the divisor is not an integer (e.g. 1.0 % 0.1 results in 0.1).
I am trying to find a solution with good performance, but hopefully doesn't make the code too messy. I assume someone has solved this problem before, but apparently my Google-fu is weak. :-(
Anyone have a solution they'd care to share?