mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Fix converting JS floating-point numbers to long (fix #228).
This commit is contained in:
parent
6f5c6cd66e
commit
daf5ada5c6
|
@ -621,7 +621,7 @@ function Long_fromNumber(val) {
|
|||
if (val >= 0) {
|
||||
return new Long(val | 0, (val / 0x100000000) | 0);
|
||||
} else {
|
||||
return new Long(val | 0, (-(Math.abs(val) / 0x100000000) - 1) | 0);
|
||||
return Long_neg(new Long(-val | 0, (-val / 0x100000000) | 0));
|
||||
}
|
||||
}
|
||||
function Long_toNumber(val) {
|
||||
|
|
|
@ -49,6 +49,13 @@ public class LongTest {
|
|||
assertEquals(2971215073L, a + b);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void smallLongDivision() {
|
||||
long a = id(-1);
|
||||
long b = 3;
|
||||
assertEquals(0, a / b);
|
||||
}
|
||||
|
||||
private static long id(long value) {
|
||||
return value;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user