def decode_val(val_text, hexnum):
    """
    Decode tile value text to its numerical equvalent.

    @param val_text: Value text to decode.
    @type  val_text: C{str}

    @param hexnum: Value is a hexadecimal number.
    @type  hexnum: C{bool}

    @return: Its numeric value if it can be decoded, C{None} if it cannot be
             decoded.
    @rtype:  C{int} or C{None}
    """
    try:
        if hexnum:
            return int(val_text, 16)
        else:
            return int(val_text, 10)
    except ValueError:
        return None