# GCD approximation for type double numbers

Hi, I am doing a phys experiment, and I find myself trying to obtain some pattern of quantization of some measurements, i.e., I'm trying to find a number (double) that divides at least a significant portion of my data, with an arbitrary remainder. Does anyone know of any algorithm that does this for type double numbers? I really need your help on this one. Thanks a lot.

Related Programming and Computer Science News on Phys.org
CRGreathouse
Homework Helper
Code:
double mod(double n, double m) {
if (n < 0)
n = -n;
if (m < 0)
m = -m;
int tmp = (int)(n / m);

return n - tmp * m;
}