public static int bitWidthOf(long value) {
        // handle edge cases
        if (value == Long.MIN_VALUE) {
            return Long.SIZE - 1;
        } else if (value == Integer.MIN_VALUE) {
            return Integer.SIZE - 1;
        } else if (value == Short.MIN_VALUE) {
            return Short.SIZE - 1;
        } else if (value == Byte.MIN_VALUE) {
            return Byte.SIZE - 1;
        }

        value = Math.abs(value);

        return Long.SIZE - Long.numberOfLeadingZeros(value);
    }
@Test
    public void testBitWidthOfLong() {
        assertEquals(0, HazelcastIntegerType.bitWidthOf(0));
        assertEquals(1, HazelcastIntegerType.bitWidthOf(1));
        assertEquals(1, HazelcastIntegerType.bitWidthOf(-1));
        assertEquals(2, HazelcastIntegerType.bitWidthOf(2));
        assertEquals(2, HazelcastIntegerType.bitWidthOf(-2));
        assertEquals(10, HazelcastIntegerType.bitWidthOf(555));
        assertEquals(10, HazelcastIntegerType.bitWidthOf(-555));

        assertEquals(Long.SIZE - 1, HazelcastIntegerType.bitWidthOf(Long.MAX_VALUE));
        assertEquals(Long.SIZE - 1, HazelcastIntegerType.bitWidthOf(Long.MIN_VALUE));

        assertEquals(Integer.SIZE - 1, HazelcastIntegerType.bitWidthOf(Integer.MAX_VALUE));
        assertEquals(Integer.SIZE - 1, HazelcastIntegerType.bitWidthOf(Integer.MIN_VALUE));

        assertEquals(Short.SIZE - 1, HazelcastIntegerType.bitWidthOf(Short.MAX_VALUE));
        assertEquals(Short.SIZE - 1, HazelcastIntegerType.bitWidthOf(Short.MIN_VALUE));

        assertEquals(Byte.SIZE - 1, HazelcastIntegerType.bitWidthOf(Byte.MAX_VALUE));
        assertEquals(Byte.SIZE - 1, HazelcastIntegerType.bitWidthOf(Byte.MIN_VALUE));
    }