@Test public void testToInt3202() { assertEquals(-2147483647d, ToInt32(-2147483647d), 0.0); assertEquals(-2147483648d, ToInt32(-2147483648d), 0.0); assertEquals(2147483647d, ToInt32(-2147483649d), 0.0); assertEquals(0d, ToInt32(-4294967296d), 0.0); assertEquals(1d, ToInt32(-4294967295d), 0.0); assertEquals(-1d, ToInt32(-4294967297d), 0.0); assertEquals(2147483646d, ToInt32(2147483646d), 0.0); assertEquals(2147483647d, ToInt32(2147483647d), 0.0); assertEquals(-2147483648d, ToInt32(2147483648d), 0.0); assertEquals(0d, ToInt32(4294967296d), 0.0); assertEquals(-1d, ToInt32(4294967295d), 0.0); assertEquals(1d, ToInt32(4294967297d), 0.0); assertEquals(-1d, ToInt32(8589934591d), 0.0); assertEquals(0d, ToInt32(8589934592d), 0.0); assertEquals(1d, ToInt32(8589934593d), 0.0); }
static Double ToInt32(Object arg) { Double number = ToNumber(arg); if (number.isNaN() || number.isInfinite() || number == 0.0) { return 0.0; } Double posInt = ToInteger(number); BigInteger posIntBig = new BigInteger(PLAIN_INTEGER_FORMAT.format(posInt)); BigInteger int32bit = posIntBig.mod(UINT_MAX_VALUE); if (int32bit.compareTo(SINT_MAX_VALUE) >= 0) { return int32bit.subtract(UINT_MAX_VALUE).doubleValue(); } return int32bit.doubleValue(); }
JSAbstractOperations { static Double ToInt32(Object arg) { Double number = ToNumber(arg); if (number.isNaN() || number.isInfinite() || number == 0.0) { return 0.0; } Double posInt = ToInteger(number); BigInteger posIntBig = new BigInteger(PLAIN_INTEGER_FORMAT.format(posInt)); BigInteger int32bit = posIntBig.mod(UINT_MAX_VALUE); if (int32bit.compareTo(SINT_MAX_VALUE) >= 0) { return int32bit.subtract(UINT_MAX_VALUE).doubleValue(); } return int32bit.doubleValue(); } }
JSAbstractOperations { static Double ToInt32(Object arg) { Double number = ToNumber(arg); if (number.isNaN() || number.isInfinite() || number == 0.0) { return 0.0; } Double posInt = ToInteger(number); BigInteger posIntBig = new BigInteger(PLAIN_INTEGER_FORMAT.format(posInt)); BigInteger int32bit = posIntBig.mod(UINT_MAX_VALUE); if (int32bit.compareTo(SINT_MAX_VALUE) >= 0) { return int32bit.subtract(UINT_MAX_VALUE).doubleValue(); } return int32bit.doubleValue(); }  }
JSAbstractOperations { static Double ToInt32(Object arg) { Double number = ToNumber(arg); if (number.isNaN() || number.isInfinite() || number == 0.0) { return 0.0; } Double posInt = ToInteger(number); BigInteger posIntBig = new BigInteger(PLAIN_INTEGER_FORMAT.format(posInt)); BigInteger int32bit = posIntBig.mod(UINT_MAX_VALUE); if (int32bit.compareTo(SINT_MAX_VALUE) >= 0) { return int32bit.subtract(UINT_MAX_VALUE).doubleValue(); } return int32bit.doubleValue(); }   }
JSAbstractOperations { static Double ToInt32(Object arg) { Double number = ToNumber(arg); if (number.isNaN() || number.isInfinite() || number == 0.0) { return 0.0; } Double posInt = ToInteger(number); BigInteger posIntBig = new BigInteger(PLAIN_INTEGER_FORMAT.format(posInt)); BigInteger int32bit = posIntBig.mod(UINT_MAX_VALUE); if (int32bit.compareTo(SINT_MAX_VALUE) >= 0) { return int32bit.subtract(UINT_MAX_VALUE).doubleValue(); } return int32bit.doubleValue(); }   static final BigInteger UINT_MAX_VALUE; static final Double UINT_MAX_VALUE_D; static final BigInteger SINT_MAX_VALUE; static final BigInteger USHORT_MAX_VALUE; }