Repository navigation
Expand file tree
/
Copy pathMaths.java
More file actions
92 lines (73 loc) · 3.29 KB
/
Copy pathMaths.java
File metadata and controls
92 lines (73 loc) · 3.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package org.tron.common.math;
/**
* This class is deprecated and should not be used in new code,
* for cross-platform consistency, please use {@link StrictMathWrapper} instead,
* especially for floating-point calculations.
*/
@Deprecated
public class Maths {
/**
* Returns the value of the first argument raised to the power of the second argument.
* @param a the base.
* @param b the exponent.
* @return the value {@code a}<sup>{@code b}</sup>.
*/
public static double pow(double a, double b, boolean useStrictMath) {
return useStrictMath ? StrictMathWrapper.pow(a, b) : MathWrapper.pow(a, b);
}
/**
* Adds two integers together, checking for overflow.
* @param x the first value.
* @param y the second value.
* @return the sum of {@code x} and {@code y}.
* @throws ArithmeticException if the result overflows an int.
*/
public static long addExact(long x, long y, boolean useStrictMath) {
return useStrictMath ? StrictMathWrapper.addExact(x, y) : MathWrapper.addExact(x, y);
}
public static int addExact(int x, int y, boolean useStrictMath) {
return useStrictMath ? StrictMathWrapper.addExact(x, y) : MathWrapper.addExact(x, y);
}
public static long floorDiv(long x, long y, boolean useStrictMath) {
return useStrictMath ? StrictMathWrapper.floorDiv(x, y) : MathWrapper.floorDiv(x, y);
}
public static int multiplyExact(int x, int y, boolean useStrictMath) {
return useStrictMath ? StrictMathWrapper.multiplyExact(x, y) : MathWrapper.multiplyExact(x, y);
}
public static long multiplyExact(long x, long y, boolean useStrictMath) {
return useStrictMath ? StrictMathWrapper.multiplyExact(x, y) : MathWrapper.multiplyExact(x, y);
}
public static long subtractExact(long x, long y, boolean useStrictMath) {
return useStrictMath ? StrictMathWrapper.subtractExact(x, y) : MathWrapper.subtractExact(x, y);
}
public static int min(int a, int b, boolean useStrictMath) {
return useStrictMath ? StrictMathWrapper.min(a, b) : MathWrapper.min(a, b);
}
public static long min(long a, long b, boolean useStrictMath) {
return useStrictMath ? StrictMathWrapper.min(a, b) : MathWrapper.min(a, b);
}
public static int max(int a, int b, boolean useStrictMath) {
return useStrictMath ? StrictMathWrapper.max(a, b) : MathWrapper.max(a, b);
}
public static long max(long a, long b, boolean useStrictMath) {
return useStrictMath ? StrictMathWrapper.max(a, b) : MathWrapper.max(a, b);
}
public static int round(float a, boolean useStrictMath) {
return useStrictMath ? StrictMathWrapper.round(a) : MathWrapper.round(a);
}
public static long round(double a, boolean useStrictMath) {
return useStrictMath ? StrictMathWrapper.round(a) : MathWrapper.round(a);
}
public static double ceil(double a, boolean useStrictMath) {
return useStrictMath ? StrictMathWrapper.ceil(a) : MathWrapper.ceil(a);
}
public static double signum(double a, boolean useStrictMath) {
return useStrictMath ? StrictMathWrapper.signum(a) : MathWrapper.signum(a);
}
public static double random(boolean useStrictMath) {
return useStrictMath ? StrictMathWrapper.random() : MathWrapper.random();
}
public static long abs(long a, boolean useStrictMath) {
return useStrictMath ? StrictMathWrapper.abs(a) : MathWrapper.abs(a);
}
}