Added a new case to expose issues that can be caused by using a floating point representation to perform integer operations (in particular, where the precision of the float isn't sufficient to cover the full integer range).
@@ -435,4 +435,18 @@ public class Nd4jIntegerTensorTest {
assertArrayEquals(new int[]{expected, expected, expected, expected}, result.asFlatIntegerArray());
}
+ @Test
+ public void canRepresentAllValues() {
+ IntegerTensor tensor = IntegerTensor.create(
+ new int[]{0,0,0,0},
+ new int[]{2, 2}
+ );
+
+ final int biggestBitRange = (0x3 << Integer.SIZE - 2) + 1;
+
+ tensor.plusInPlace(biggestBitRange);
+ assertArrayEquals(new int[]{biggestBitRange, biggestBitRange, biggestBitRange, biggestBitRange},
+ tensor.asFlatIntegerArray());
+ }
+
}
