public static boolean isNaN(final Object object) {
        return (object instanceof Float && Float.isNaN((float) object)) ||
                (object instanceof Double && Double.isNaN((double) object));
    }
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