def METHOD_NAME(self):
    typ = Type(self)
    if typ == 'Number':  # or self.Class=='Number':   # no need to convert
        return self
    elif typ == 'Null':  # null is 0
        return 0.
    elif typ == 'Undefined':  # undefined is NaN
        return NaN
    elif typ == 'Boolean':  # 1 for True 0 for false
        return float(self)
    elif typ == 'String':
        s = self.strip()  # Strip white space
        if not s:  # '' is simply 0
            return 0.
        if 'x' in s or 'X' in s[:3]:  # hex (positive only)
            try:  # try to convert
                num = int(s, 16)
            except ValueError:  # could not convert -> NaN
                return NaN
            return float(num)
        sign = 1  # get sign
        if s[0] in '+-':
            if s[0] == '-':
                sign = -1
            s = s[1:]
        if s == 'Infinity':  # Check for infinity keyword. 'NaN' will be NaN anyway.
            return sign * Infinity
        try:  # decimal try
            num = sign * float(s)  # Converted
        except ValueError:
            return NaN  # could not convert to decimal  > return NaN
        return float(num)
    else:  # object -  most likely it will be NaN.
        return METHOD_NAME(to_primitive(self, 'Number'))