public BigDecimal getAsDecimal() {
        if (asDecimal == null) {
            isNumeric = true;
            try {
                if (raw instanceof BigDecimal) {
                    asDecimal = (BigDecimal) raw;
                } else if (raw instanceof Integer || raw instanceof Long || raw instanceof Byte) {
                    asDecimal = new BigDecimal(((Number) raw).longValue());
                } else if (raw instanceof Double || raw instanceof Float) {
                    asDecimal = BigDecimal.valueOf(((Number) raw).doubleValue());
                } else if (raw instanceof BigInteger) {
                    asDecimal = new BigDecimal((BigInteger) raw);
                } else {
                    asDecimal = new BigDecimal(getAsString().replace(',', '.'));
                }
            } catch (NumberFormatException ignore) {
                isNumeric = false;
                asDecimal = BigDecimal.ZERO;
            }
        }
        return asDecimal;
    }
Encapsulates a single value for handling in {@link Formula}. Provides e.g. type conversions.
<br>
Supports raw values of type String, CharSequence, Double, Long, BigInterger and BigDecimal
main/src/main/java/cgeo/geocaching/utils/formulas/Value.java