Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

GCD approximation for type double numbers

  1. Nov 5, 2007 #1
    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.
  2. jcsd
  3. Nov 5, 2007 #2


    User Avatar
    Science Advisor
    Homework Helper

    Code (Text):
    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;
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?

Similar Discussions: GCD approximation for type double numbers
  1. Gcd method (Replies: 4)