def get_as_num(value):
    """Return the JS numeric equivalent for a value."""
    if hasattr(value, 'get_literal_value'):
        value = value.get_literal_value()

    if value is None:
        return 0

    try:
        if isinstance(value, types.StringTypes):
            if value.startswith("0x"):
                return int(value, 16)
            else:
                return float(value)
        elif isinstance(value, (int, float, long)):
            return value
        else:
            return int(value)
    except (ValueError, __HOLE__):
        return 0
dataset/ETHPy150Open mozilla/app-validator/appvalidator/testcases/javascript/utils.py/get_as_num