Here you can find the source of gcd(double a, double b)
public static double gcd(double a, double b)
//package com.java2s; public class Main { public static double gcd(double a, double b) { double epsilon = 1.0 / (1L << 32); while (a > epsilon) { if (a < b) { // Swap double swap = a; a = b;/* w w w . ja va 2 s. c o m*/ b = swap; } a = a % b; } return b; } public static double gcd(double... values) { if (values.length == 0) throw new IllegalArgumentException("gcd() requires at least one value"); double result = values[0]; for (int i = 1; i < values.length; i++) result = gcd(result, values[i]); return result; } }