public static long[] toFraction(double number) {
final BigDecimal bigDecimal = BigDecimal.valueOf(number);
final int decimalPlaces = bigDecimal.scale();
final BigDecimal divisor = BigDecimal.TEN.pow(decimalPlaces);
final BigDecimal dividend = bigDecimal.movePointRight(decimalPlaces);
final BigInteger divisorInt = BigInteger.valueOf(divisor.longValue());
final BigInteger dividendInt = BigInteger.valueOf(dividend.longValue());
final BigInteger greatestCommonDivisor = divisorInt.gcd(dividendInt);
return new long[] {
dividendInt.divide(greatestCommonDivisor).longValue(),
divisorInt.divide(greatestCommonDivisor).longValue(),
};
}