mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Add Math.floorMod and Math.floorDiv (#544)
This commit is contained in:
parent
bec0f44869
commit
98f5c5da73
|
@ -127,6 +127,32 @@ public final class TMath extends TObject {
|
|||
return (long) (a + signum(a) * 0.5);
|
||||
}
|
||||
|
||||
public static int floorDiv(int a, int b) {
|
||||
int div = a / b;
|
||||
return (a ^ b) < 0 && div * b != a ? div - 1 : div;
|
||||
}
|
||||
|
||||
public static long floorDiv(long a, int b) {
|
||||
return floorDiv(a, (long) b);
|
||||
}
|
||||
|
||||
public static long floorDiv(long a, long b) {
|
||||
long div = a / b;
|
||||
return (a ^ b) < 0 && div * b != a ? div - 1 : div;
|
||||
}
|
||||
|
||||
public static int floorMod(int a, int b) {
|
||||
return a - floorDiv(a, b) * b;
|
||||
}
|
||||
|
||||
public static int floorMod(long a, int b) {
|
||||
return (int) (a - floorDiv(a, b) * b);
|
||||
}
|
||||
|
||||
public static long floorMod(long a, long b) {
|
||||
return a - floorDiv(a, b) * b;
|
||||
}
|
||||
|
||||
@Unmanaged
|
||||
public static double random() {
|
||||
return PlatformDetector.isC() ? randomC() : randomImpl();
|
||||
|
|
Loading…
Reference in New Issue
Block a user