private BigDecimal toBigDecimal(Number value) {
        if (value instanceof BigDecimal) {
            return (BigDecimal) value;
        } else if (value instanceof Integer || value instanceof Long
                || value instanceof Short
                || value instanceof Byte) {
            return BigDecimal.valueOf(value.longValue());
        } else if (value instanceof Float || value instanceof Double) {
            double d = value.doubleValue();
            if (Double.isNaN(d)) {
                isNaN = true;
                return null;
            } else if (Double.isInfinite(d)) {
                if (stringCache.startsWith("-")) {
                    isNegativeInfinity = true;
                } else {
                    isPositiveInfinity = true;
                }
                return null;
            } else {
                return BigDecimal.valueOf(d);
            }
        } else if (value instanceof BigInteger) {
            return new BigDecimal((BigInteger) value);
        } else {
            return new BigDecimal(stringCache);
        }
    }
Represents a number node. Number nodes contain a {@code Number} value.

<p>Number nodes contain a value. You can inspect its type by calling
{@code isNaturalNumber()} or {@code isFloatingPointNumber()}. Natural
numbers are positive, or negative numbers without a decimal part.
smithy-model/src/main/java/software/amazon/smithy/model/node/NumberNode.java