blob: 986771a1332e131439e5e403ccfab025aa2509a3 (
plain) (
blame)
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
|
/*
* SPDX-FileCopyrightText: 2023 The Refinery Authors <https://refinery.tools/>
*
* SPDX-License-Identifier: EPL-2.0
*/
package tools.refinery.store.reasoning.scope;
final class RoundingUtil {
private static final double TOLERANCE = 0.01;
private RoundingUtil() {
throw new IllegalStateException("This is a static utility class and should not be instantiated directly");
}
public static int roundUp(double value) {
double ceil = Math.ceil(value - TOLERANCE);
int intCeil = (int) ceil;
return Math.max(intCeil, 0);
}
public static int roundDown(double value) {
double floor = Math.floor(value + TOLERANCE);
int intFloor = (int) floor;
return Math.max(intFloor, 0);
}
}
|