@Test
    public void shouldSubtractAndReturnCorrectType() {
        assertEquals((byte) 1, sub((byte) 1, (Byte) null));
        assertNull(sub((Byte) null, (byte) 1));

        // BYTE
        assertEquals((byte) 0, sub((byte) 1, (byte) 1));
        assertEquals((short) 0, sub((byte) 1, (short) 1));
        assertEquals(0, sub((byte) 1, 1));
        assertEquals(0L, sub((byte) 1, 1L));
        assertEquals(0F, sub((byte) 1, 1F));
        assertEquals(0D, sub((byte) 1, 1D));
        assertEquals(BigInteger.ZERO, sub((byte) 1, BigInteger.ONE));
        assertEquals(BigDecimal.ZERO, sub((byte) 1, BigDecimal.ONE));

        // SHORT
        assertEquals((short) 0, sub((short) 1, (short) 1));
        assertEquals(0, sub((short) 1, 1));
        assertEquals(0L, sub((short) 1, 1L));
        assertEquals(0F, sub((short) 1, 1F));
        assertEquals(0D, sub((short) 1, 1D));
        assertEquals(BigInteger.ZERO, sub((short) 1, BigInteger.ONE));
        assertEquals(BigDecimal.ZERO, sub((short) 1, BigDecimal.ONE));

        // INTEGER
        assertEquals(0, sub(1, 1));
        assertEquals(0L, sub(1, 1L));
        assertEquals(0F, sub(1, 1F));
        assertEquals(0D, sub(1, 1D));
        assertEquals(BigInteger.ZERO, sub(1, BigInteger.ONE));
        assertEquals(BigDecimal.ZERO, sub(1, BigDecimal.ONE));

        // LONG
        assertEquals(0L, sub(1L, 1L));
        assertEquals(0D, sub(1L, 1F));
        assertEquals(0D, sub(1L, 1D));
        assertEquals(BigInteger.ZERO, sub(1L, BigInteger.ONE));
        assertEquals(BigDecimal.ZERO, sub(1L, BigDecimal.ONE));

        // FLOAT
        assertEquals(0F, sub(1F, 1F));
        assertEquals(0D, sub(1F, 1D));
        assertEquals(BigDecimal.ZERO.setScale(1, RoundingMode.HALF_UP), sub(1F, BigInteger.ONE));
        assertEquals(BigDecimal.ZERO.setScale(1, RoundingMode.HALF_UP), sub(1F, BigDecimal.ONE));

        // DOUBLE
        assertEquals(0D, sub(1D, 1D));
        assertEquals(BigDecimal.ZERO.setScale(1, RoundingMode.HALF_UP), sub(1D, BigInteger.ONE));
        assertEquals(BigDecimal.ZERO.setScale(1, RoundingMode.HALF_UP), sub(1D, BigDecimal.ONE));

        // BIG INTEGER
        assertEquals(BigInteger.ZERO, sub(BigInteger.ONE, BigInteger.ONE));
        assertEquals(BigDecimal.ZERO, sub(BigInteger.ONE, BigDecimal.ONE));

        // BIG DECIMAL
        assertEquals(BigDecimal.ZERO, sub(BigDecimal.ONE, BigDecimal.ONE));
    }
@author Daniel Kuppitz (http://gremlin.guru)
gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/NumberHelperTest.java