|
@@ -8,120 +8,235 @@ package net.ranides.assira.math;
|
|
|
|
|
|
|
|
import lombok.experimental.UtilityClass;
|
|
import lombok.experimental.UtilityClass;
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * Math methods, obviously.
|
|
|
|
|
+ */
|
|
|
@UtilityClass
|
|
@UtilityClass
|
|
|
public final class MathUtils {
|
|
public final class MathUtils {
|
|
|
|
|
|
|
|
- private static double EPSILON = Math.pow(2, -52);
|
|
|
|
|
- private static double MAX_VALUE = (2 - EPSILON) * Math.pow(2, 1023);
|
|
|
|
|
- private static double MIN_VALUE = Math.pow(2, -1022);
|
|
|
|
|
-
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Returns true if {@code min <= value <= max}
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param value value
|
|
|
|
|
+ * @param min min
|
|
|
|
|
+ * @param max max
|
|
|
|
|
+ * @return boolean
|
|
|
|
|
+ */
|
|
|
public static boolean between(int value, int min, int max) {
|
|
public static boolean between(int value, int min, int max) {
|
|
|
return value >= min && value <= max;
|
|
return value >= min && value <= max;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Returns true if {@code min <= value <= max}
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param value value
|
|
|
|
|
+ * @param min min
|
|
|
|
|
+ * @param max max
|
|
|
|
|
+ * @return boolean
|
|
|
|
|
+ */
|
|
|
public static boolean between(byte value, byte min, byte max) {
|
|
public static boolean between(byte value, byte min, byte max) {
|
|
|
return value >= min && value <= max;
|
|
return value >= min && value <= max;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Returns true if {@code min <= value <= max}
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param value value
|
|
|
|
|
+ * @param min min
|
|
|
|
|
+ * @param max max
|
|
|
|
|
+ * @return boolean
|
|
|
|
|
+ */
|
|
|
public static boolean between(long value, long min, long max) {
|
|
public static boolean between(long value, long min, long max) {
|
|
|
return value >= min && value <= max;
|
|
return value >= min && value <= max;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Returns value if {@code min <= value <= max}.
|
|
|
|
|
+ * Returns min for smaller values, returns max for greater values.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param value value
|
|
|
|
|
+ * @param min min
|
|
|
|
|
+ * @param max max
|
|
|
|
|
+ * @return number
|
|
|
|
|
+ */
|
|
|
public static int clip(int value, int min, int max) {
|
|
public static int clip(int value, int min, int max) {
|
|
|
assert min <= max;
|
|
assert min <= max;
|
|
|
return value < min ? min : value > max ? max : value;
|
|
return value < min ? min : value > max ? max : value;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Returns value if {@code min <= value <= max}.
|
|
|
|
|
+ * Returns min for smaller values, returns max for greater values.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param value value
|
|
|
|
|
+ * @param min min
|
|
|
|
|
+ * @param max max
|
|
|
|
|
+ * @return number
|
|
|
|
|
+ */
|
|
|
public static long clip(long value, long min, long max) {
|
|
public static long clip(long value, long min, long max) {
|
|
|
assert min <= max;
|
|
assert min <= max;
|
|
|
return value < min ? min : value > max ? max : value;
|
|
return value < min ? min : value > max ? max : value;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Returns value if {@code min <= value <= max}.
|
|
|
|
|
+ * Returns min for smaller values, returns max for greater values.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param value value
|
|
|
|
|
+ * @param min min
|
|
|
|
|
+ * @param max max
|
|
|
|
|
+ * @return number
|
|
|
|
|
+ */
|
|
|
public static double clip(double value, double min, double max) {
|
|
public static double clip(double value, double min, double max) {
|
|
|
assert min <= max;
|
|
assert min <= max;
|
|
|
return value < min ? min : value > max ? max : value;
|
|
return value < min ? min : value > max ? max : value;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Returns value if {@code min <= value <= max}.
|
|
|
|
|
+ * Returns min for smaller values, returns max for greater values.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param value value
|
|
|
|
|
+ * @param min min
|
|
|
|
|
+ * @param max max
|
|
|
|
|
+ * @return number
|
|
|
|
|
+ */
|
|
|
public static float clip(float value, float min, float max) {
|
|
public static float clip(float value, float min, float max) {
|
|
|
assert min <= max;
|
|
assert min <= max;
|
|
|
return value < min ? min : value > max ? max : value;
|
|
return value < min ? min : value > max ? max : value;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Returns rounded value if {@code min <= value <= max}.
|
|
|
|
|
+ * Returns min for smaller values, returns max for greater values.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param value value
|
|
|
|
|
+ * @param min min
|
|
|
|
|
+ * @param max max
|
|
|
|
|
+ * @return number
|
|
|
|
|
+ */
|
|
|
public static int round(double value, int min, int max) {
|
|
public static int round(double value, int min, int max) {
|
|
|
assert min <= max;
|
|
assert min <= max;
|
|
|
return (int)Math.round(value < min ? min : value > max ? max : value);
|
|
return (int)Math.round(value < min ? min : value > max ? max : value);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Returns rounded value if {@code min <= value <= max}.
|
|
|
|
|
+ * Returns min for smaller values, returns max for greater values.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param value value
|
|
|
|
|
+ * @param min min
|
|
|
|
|
+ * @param max max
|
|
|
|
|
+ * @return number
|
|
|
|
|
+ */
|
|
|
public static long round(double value, long min, long max) {
|
|
public static long round(double value, long min, long max) {
|
|
|
assert min <= max;
|
|
assert min <= max;
|
|
|
return Math.round(value < min ? min : value > max ? max : value);
|
|
return Math.round(value < min ? min : value > max ? max : value);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Returns true signum: +1 for positives, -1 for negatives, 0 for zero.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param diff diff
|
|
|
|
|
+ * @return int
|
|
|
|
|
+ */
|
|
|
public static int signum(int diff) {
|
|
public static int signum(int diff) {
|
|
|
return Integer.signum(diff);
|
|
return Integer.signum(diff);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
- * Alternate to signum for use in compare. Not a true signum, since it
|
|
|
|
|
- * returns ints other than +/-1. Where there is any possibility of overflow,
|
|
|
|
|
- * you should compare two longs with < rather than subtraction.
|
|
|
|
|
- * <p>
|
|
|
|
|
- * In Pentium assembler you could implement this algorthm with following code:
|
|
|
|
|
- * <pre>
|
|
|
|
|
- * # diff = edx:eax
|
|
|
|
|
- * # result = eax
|
|
|
|
|
- * mov ebx,eax
|
|
|
|
|
- * shl eax,1
|
|
|
|
|
- * or eax,ebx
|
|
|
|
|
- * slr eax,1
|
|
|
|
|
- * or eax,edx
|
|
|
|
|
- * </pre>
|
|
|
|
|
- * which would take 5 cycles, 2 more that lohi. However, JET did even better,
|
|
|
|
|
- * with code essentially this using a clever trick to implement piotr.
|
|
|
|
|
- * <pre>
|
|
|
|
|
- * lea ecx,0(eax,eax) ; shifts lo left by doubling, keeps copy of
|
|
|
|
|
- * lo
|
|
|
|
|
- * or eax,ecx
|
|
|
|
|
- * shr eax,1
|
|
|
|
|
- * or eax,edx
|
|
|
|
|
- * </pre>
|
|
|
|
|
- * This is 4 cycles, still one more than lohi. Why was Piotr so much
|
|
|
|
|
- * faster on JET? Peter has no pipeline-confounding jumps. Further, the lo
|
|
|
|
|
- * then high operands actually come from the ram-based stack. Piotr nicely
|
|
|
|
|
- * separates the accesses giving plenty of for pre-emptive fetch of hi.
|
|
|
|
|
- * lohi insists on having them both upfront, so it has to wait for memory
|
|
|
|
|
- * access. Piotr does not have to wait. Modern CPUS hurry up and wait for
|
|
|
|
|
- * RAM most of the time.
|
|
|
|
|
- *
|
|
|
|
|
- * @param diff number to be collapsed to an int preserving sign and
|
|
|
|
|
- * zeroness. usually represents the difference of two long.
|
|
|
|
|
- *
|
|
|
|
|
- * @return sign of {@code diff}, some {@code int < 0}, 0 or some {@code int > 0}.
|
|
|
|
|
- * @author Peter Kobzda
|
|
|
|
|
|
|
+ * Returns pseduo-signum.
|
|
|
|
|
+ * Returns some positive int for diff > 0
|
|
|
|
|
+ * Returns some negative int for diff < 0
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param diff diff
|
|
|
|
|
+ * @return int
|
|
|
*/
|
|
*/
|
|
|
public static int signum(long diff) {
|
|
public static int signum(long diff) {
|
|
|
|
|
+ /*
|
|
|
|
|
+ * Alternative to signum for use in compare. Not a true signum, since it
|
|
|
|
|
+ * returns ints other than +/-1. Where there is any possibility of overflow,
|
|
|
|
|
+ * you should compare two longs with < rather than subtraction.
|
|
|
|
|
+ * <p>
|
|
|
|
|
+ * In Pentium assembler you could implement this algorthm with following code:
|
|
|
|
|
+ * <pre>
|
|
|
|
|
+ * # diff = edx:eax
|
|
|
|
|
+ * # result = eax
|
|
|
|
|
+ * mov ebx,eax
|
|
|
|
|
+ * shl eax,1
|
|
|
|
|
+ * or eax,ebx
|
|
|
|
|
+ * slr eax,1
|
|
|
|
|
+ * or eax,edx
|
|
|
|
|
+ * </pre>
|
|
|
|
|
+ * which would take 5 cycles, 2 more that lohi. However, JET did even better,
|
|
|
|
|
+ * with code essentially this using a clever trick to implement piotr.
|
|
|
|
|
+ * <pre>
|
|
|
|
|
+ * lea ecx,0(eax,eax) ; shifts lo left by doubling, keeps copy of
|
|
|
|
|
+ * lo
|
|
|
|
|
+ * or eax,ecx
|
|
|
|
|
+ * shr eax,1
|
|
|
|
|
+ * or eax,edx
|
|
|
|
|
+ * </pre>
|
|
|
|
|
+ * This is 4 cycles, still one more than lohi. Why was Piotr so much
|
|
|
|
|
+ * faster on JET? Peter has no pipeline-confounding jumps. Further, the lo
|
|
|
|
|
+ * then high operands actually come from the ram-based stack. Piotr nicely
|
|
|
|
|
+ * separates the accesses giving plenty of for pre-emptive fetch of hi.
|
|
|
|
|
+ * lohi insists on having them both upfront, so it has to wait for memory
|
|
|
|
|
+ * access. Piotr does not have to wait. Modern CPUS hurry up and wait for
|
|
|
|
|
+ * RAM most of the time.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param diff number to be collapsed to an int preserving sign and
|
|
|
|
|
+ * zeroness. usually represents the difference of two long.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @return sign of {@code diff}, some {@code int < 0}, 0 or some {@code int > 0}.
|
|
|
|
|
+ * @author Peter Kobzda
|
|
|
|
|
+ */
|
|
|
return (int) (diff >>> 32) | ((int) diff | (int) diff << 1) >>> 1;
|
|
return (int) (diff >>> 32) | ((int) diff | (int) diff << 1) >>> 1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Calculates floor( log2(x) )
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param x x
|
|
|
|
|
+ * @return int
|
|
|
|
|
+ */
|
|
|
public static int log2floor(int x) {
|
|
public static int log2floor(int x) {
|
|
|
return 31 - Integer.numberOfLeadingZeros(x);
|
|
return 31 - Integer.numberOfLeadingZeros(x);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Calculates floor( log2(x) )
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param x x
|
|
|
|
|
+ * @return int
|
|
|
|
|
+ */
|
|
|
public static int log2floor(long x) {
|
|
public static int log2floor(long x) {
|
|
|
return 63 - Long.numberOfLeadingZeros(x);
|
|
return 63 - Long.numberOfLeadingZeros(x);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Calculates ceil( log2(x) )
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param x x
|
|
|
|
|
+ * @return int
|
|
|
|
|
+ */
|
|
|
public static int log2ceil(int x) {
|
|
public static int log2ceil(int x) {
|
|
|
return 32 - Integer.numberOfLeadingZeros(x - 1);
|
|
return 32 - Integer.numberOfLeadingZeros(x - 1);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Calculates ceil( log2(x) )
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param x x
|
|
|
|
|
+ * @return int
|
|
|
|
|
+ */
|
|
|
public static int log2ceil(long x) {
|
|
public static int log2ceil(long x) {
|
|
|
return 64 - Long.numberOfLeadingZeros(x - 1);
|
|
return 64 - Long.numberOfLeadingZeros(x - 1);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * Return the least power of two greater than or equal to the specified
|
|
|
|
|
- * value.
|
|
|
|
|
|
|
+ * Return the least power of two greater than or equal to the specified value.
|
|
|
*
|
|
*
|
|
|
* <p>Note that this function will return 1 when the argument is 0.
|
|
* <p>Note that this function will return 1 when the argument is 0.
|
|
|
*
|
|
*
|
|
@@ -145,8 +260,7 @@ public final class MathUtils {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * Return the least power of two greater than or equal to the specified
|
|
|
|
|
- * value.
|
|
|
|
|
|
|
+ * Return the least power of two greater than or equal to the specified value.
|
|
|
*
|
|
*
|
|
|
* <p>Note that this function will return 1 when the argument is 0.
|
|
* <p>Note that this function will return 1 when the argument is 0.
|
|
|
*
|
|
*
|
|
@@ -170,14 +284,33 @@ public final class MathUtils {
|
|
|
return (x | x >> 32) + 1;
|
|
return (x | x >> 32) + 1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Calculates a * a
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param a a
|
|
|
|
|
+ * @return double
|
|
|
|
|
+ */
|
|
|
public static double square(double a) {
|
|
public static double square(double a) {
|
|
|
return a * a;
|
|
return a * a;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- public static int gcd(int a, int b) {
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Calculates greates common divisor
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param a a
|
|
|
|
|
+ * @param b b
|
|
|
|
|
+ * @return int
|
|
|
|
|
+ */
|
|
|
|
|
+ public static int gcd(int a, int b) {
|
|
|
return b==0 ? a : gcd(b, a % b);
|
|
return b==0 ? a : gcd(b, a % b);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Calculates greates common divisor
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param values values
|
|
|
|
|
+ * @return int
|
|
|
|
|
+ */
|
|
|
public static int gcd(int... values) {
|
|
public static int gcd(int... values) {
|
|
|
int ret = gcd(values[0], values[1]);
|
|
int ret = gcd(values[0], values[1]);
|
|
|
for(int i=2; i<values.length; i++) {
|
|
for(int i=2; i<values.length; i++) {
|
|
@@ -185,11 +318,24 @@ public final class MathUtils {
|
|
|
}
|
|
}
|
|
|
return ret;
|
|
return ret;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- public static long gcd(long a, long b) {
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Calculates greates common divisor
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param a a
|
|
|
|
|
+ * @param b b
|
|
|
|
|
+ * @return long
|
|
|
|
|
+ */
|
|
|
|
|
+ public static long gcd(long a, long b) {
|
|
|
return b==0 ? a : gcd(b, a % b);
|
|
return b==0 ? a : gcd(b, a % b);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Calculates greates common divisor
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param values values
|
|
|
|
|
+ * @return long
|
|
|
|
|
+ */
|
|
|
public static long gcd(long... values) {
|
|
public static long gcd(long... values) {
|
|
|
long ret = gcd(values[0], values[1]);
|
|
long ret = gcd(values[0], values[1]);
|
|
|
for(int i=2; i<values.length; i++) {
|
|
for(int i=2; i<values.length; i++) {
|
|
@@ -197,11 +343,24 @@ public final class MathUtils {
|
|
|
}
|
|
}
|
|
|
return ret;
|
|
return ret;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Calculates least common multiple
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param a a
|
|
|
|
|
+ * @param b a
|
|
|
|
|
+ * @return int
|
|
|
|
|
+ */
|
|
|
public static int lcm(int a, int b) {
|
|
public static int lcm(int a, int b) {
|
|
|
return (a / gcd(a,b)) * b;
|
|
return (a / gcd(a,b)) * b;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Calculates least common multiple
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param values values
|
|
|
|
|
+ * @return int
|
|
|
|
|
+ */
|
|
|
public static int lcm(int... values) {
|
|
public static int lcm(int... values) {
|
|
|
int ret = lcm(values[0], values[1]);
|
|
int ret = lcm(values[0], values[1]);
|
|
|
for(int i=2; i<values.length; i++) {
|
|
for(int i=2; i<values.length; i++) {
|
|
@@ -209,11 +368,24 @@ public final class MathUtils {
|
|
|
}
|
|
}
|
|
|
return ret;
|
|
return ret;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Calculates least common multiple
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param a a
|
|
|
|
|
+ * @param b b
|
|
|
|
|
+ * @return long
|
|
|
|
|
+ */
|
|
|
public static long lcm(long a, long b) {
|
|
public static long lcm(long a, long b) {
|
|
|
return (a/ gcd(a,b) ) * b;
|
|
return (a/ gcd(a,b) ) * b;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Calculates least common multiple
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param values values
|
|
|
|
|
+ * @return long
|
|
|
|
|
+ */
|
|
|
public static long lcm(long... values) {
|
|
public static long lcm(long... values) {
|
|
|
long ret = lcm(values[0], values[1]);
|
|
long ret = lcm(values[0], values[1]);
|
|
|
for(int i=2; i<values.length; i++) {
|
|
for(int i=2; i<values.length; i++) {
|
|
@@ -278,43 +450,5 @@ public final class MathUtils {
|
|
|
return clip(adds(x,y), min, max);
|
|
return clip(adds(x,y), min, max);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public static double ulp(double x) {
|
|
|
|
|
- return x < 0 ? nextUp(x) - x : x - nextDown(x);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public static double nextDown(double x) {
|
|
|
|
|
- return -nextUp(-x);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public static double nextUp(double x) {
|
|
|
|
|
- if (x != x) {
|
|
|
|
|
- return x;
|
|
|
|
|
- }
|
|
|
|
|
- if (x == -1 / 0) {
|
|
|
|
|
- return -MAX_VALUE;
|
|
|
|
|
- }
|
|
|
|
|
- if (x == +1 / 0) {
|
|
|
|
|
- return +1 / 0;
|
|
|
|
|
- }
|
|
|
|
|
- if (x == +MAX_VALUE) {
|
|
|
|
|
- return +1 / 0;
|
|
|
|
|
- }
|
|
|
|
|
- double y = x * (x < 0 ? 1 - EPSILON / 2 : 1 + EPSILON);
|
|
|
|
|
- if (y == x) {
|
|
|
|
|
- y = MIN_VALUE * EPSILON > 0 ? x + MIN_VALUE * EPSILON : x + MIN_VALUE;
|
|
|
|
|
- }
|
|
|
|
|
- if (y == +1 / 0) {
|
|
|
|
|
- y = +MAX_VALUE;
|
|
|
|
|
- }
|
|
|
|
|
- double b = x + (y - x) / 2;
|
|
|
|
|
- if (x < b && b < y) {
|
|
|
|
|
- y = b;
|
|
|
|
|
- }
|
|
|
|
|
- double c = (y + x) / 2;
|
|
|
|
|
- if (x < c && c < y) {
|
|
|
|
|
- y = c;
|
|
|
|
|
- }
|
|
|
|
|
- return y == 0 ? -0 : y;
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|