public static int compare(Object a, Object b) {
        final Class typeA = a.getClass(), typeB = b.getClass();

        if (typeA == typeB) {
            return ((Comparable) a).compareTo(b);
        }

        if (typeA == BigDecimal.class) {
            if (typeB == Integer.class || typeB == Long.class) {
                b = BigDecimal.valueOf(((Number) b).longValue());
            } else if (typeB == Float.class || typeB == Double.class) {
                b = BigDecimal.valueOf(((Number) b).doubleValue());
            } else if (typeB == BigInteger.class) {
                b = new BigDecimal((BigInteger) b);
            }
        } else if (typeA == BigInteger.class) {
            if (typeB == Integer.class || typeB == Long.class) {
                b = BigInteger.valueOf(((Number) b).longValue());
            } else if (typeB == Float.class || typeB == Double.class) {
                b = BigDecimal.valueOf(((Number) b).doubleValue());
                a = new BigDecimal((BigInteger) a);
            } else if (typeB == BigDecimal.class) {
                a = new BigDecimal((BigInteger) a);
            }
        } else if (typeA == Long.class) {
            if (typeB == Integer.class) {
                return Long.compare((Long) a, ((Integer) b));
            } else if (typeB == BigDecimal.class) {
                a = BigDecimal.valueOf((Long) a);
            } else if (typeB == Float.class || typeB == Double.class) {
                return Double.compare((Long) a, ((Number) b).doubleValue());
            } else if (typeB == BigInteger.class) {
                a = BigInteger.valueOf((Long) a);
            } else if (typeB == String.class) {
                a = BigDecimal.valueOf((Long) a);
                b = new BigDecimal((String) b);
            }
        } else if (typeA == Integer.class) {
            if (typeB == Long.class) {
                return Long.compare((Integer) a, ((Long) b));
            } else if (typeB == BigDecimal.class) {
                a = BigDecimal.valueOf((Integer) a);
            } else if (typeB == BigInteger.class) {
                a = BigInteger.valueOf((Integer) a);
            } else if (typeB == Float.class || typeB == Double.class) {
                return Double.compare((Integer) a, ((Number) b).doubleValue());
            } else if (typeB == String.class) {
                a = BigDecimal.valueOf((Integer) a);
                b = new BigDecimal((String) b);
            }
        } else if (typeA == Double.class) {
            if (typeB == Integer.class || typeB == Long.class || typeB == Float.class) {
                return Double.compare((Double) a, ((Number) b).doubleValue());
            } else if (typeB == BigDecimal.class) {
                a = BigDecimal.valueOf((Double) a);
            } else if (typeB == String.class) {
                a = BigDecimal.valueOf((Double) a);
                b = new BigDecimal((String) b);
            } else if (typeB == BigInteger.class) {
                a = BigDecimal.valueOf((Double) a);
                b = new BigDecimal((BigInteger) b);
            }
        } else if (typeA == Float.class) {
            if (typeB == Integer.class || typeB == Long.class || typeB == Double.class) {
                return Double.compare((Float) a, ((Number) b).doubleValue());
            } else if (typeB == BigDecimal.class) {
                a = BigDecimal.valueOf((Float) a);
            } else if (typeB == String.class) {
                a = BigDecimal.valueOf((Float) a);
                b = new BigDecimal((String) b);
            } else if (typeB == BigInteger.class) {
                a = BigDecimal.valueOf((Float) a);
                b = new BigDecimal((BigInteger) b);
            }
        } else if (typeA == String.class) {
            String strA = (String) a;
            if (typeB == Integer.class || typeB == Long.class) {
                try {
                    long aVal = Long.parseLong(strA);
                    return Long.compare(aVal, ((Number) b).longValue());
                } catch (NumberFormatException ex) {
                    a = new BigDecimal(strA);
                    b = BigDecimal.valueOf(((Number) b).longValue());
                }
            } else if (typeB == Float.class || typeB == Double.class) {
                return Double.compare(Double.parseDouble(strA), ((Number) b).doubleValue());
            } else if (typeB == BigInteger.class) {
                a = new BigInteger(strA);
            } else if (typeB == BigDecimal.class) {
                a = new BigDecimal(strA);
            }
        }

        return ((Comparable) a).compareTo(b);
    }
decimal is integer, check has non-zero small

@param decimal
@return
core/src/main/java/com/alibaba/fastjson2/util/TypeUtils.java