private static Class<? extends Number> determineNumberClass(final int bits, final boolean floatingPoint) {
        if (floatingPoint) {
            if (bits <= 32) return Float.class;
            if (bits <= 64) return Double.class;
            return BigDecimal.class;
        } else {
            if (bits <= 8) return Byte.class;
            if (bits <= 16) return Short.class;
            if (bits <= 32) return Integer.class;
            if (bits <= 64) return Long.class;
            return BigInteger.class;
        }
    }
Coerces the given number to the specified numeric type if it can fit into it.
Otherwise, retains the original type.

@param a the number to be coerced
@param clazz the target numeric type class
@return the coerced number in the specified type or the original type if it cannot fit
@throws IllegalArgumentException if the specified numeric type is unsupported
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/NumberHelper.java