--- old/modules/javafx.graphics/src/main/java/com/sun/marlin/FloatMath.java 2016-11-30 22:45:17.670404419 +0100 +++ new/modules/javafx.graphics/src/main/java/com/sun/marlin/FloatMath.java 2016-11-30 22:45:17.446404402 +0100 @@ -44,6 +44,11 @@ return (a >= b) ? a : b; } + static double max(final double a, final double b) { + // no NaN handling + return (a >= b) ? a : b; + } + public static int max(final int a, final int b) { return (a >= b) ? a : b; } @@ -73,6 +78,26 @@ } /** + * Faster alternative to ceil(double) optimized for the integer domain + * and supporting NaN and +/-Infinity. + * + * @param a a value. + * @return the largest (closest to positive infinity) integer value + * that less than or equal to the argument and is equal to a mathematical + * integer. + */ + public static int ceil_int(final double a) { + final int intpart = (int) a; + + if (a <= intpart + || (CHECK_OVERFLOW && intpart == Integer.MAX_VALUE) + || CHECK_NAN && Double.isNaN(a)) { + return intpart; + } + return intpart + 1; + } + + /** * Faster alternative to floor(float) optimized for the integer domain * and supporting NaN and +/-Infinity. * @@ -90,5 +115,25 @@ return intpart; } return intpart - 1; + } + + /** + * Faster alternative to floor(double) optimized for the integer domain + * and supporting NaN and +/-Infinity. + * + * @param a a value. + * @return the largest (closest to positive infinity) floating-point value + * that less than or equal to the argument and is equal to a mathematical + * integer. + */ + public static int floor_int(final double a) { + final int intpart = (int) a; + + if (a >= intpart + || (CHECK_OVERFLOW && intpart == Integer.MIN_VALUE) + || CHECK_NAN && Double.isNaN(a)) { + return intpart; + } + return intpart - 1; } }