private static int bcd(char digit) {
        if (digit >= '0' && digit <= '9') {
            return digit - '0';
        }
        switch (digit) {
            case '.':
                return 10;
            case '-':
                return 11;
            case '+':
                return 12;
            default:
                return 13;
        }
    }