unsupported operand type(s) for ^: 'float' and 'float'

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Florian Lindner

    unsupported operand type(s) for ^: 'float' and 'float'

    Hello,
    I get the exception above when trying to use a float as radix and exponent,
    e.g.:
    >>5.3^4.3
    Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    TypeError: unsupported operand type(s) for ^: 'float' and 'float'


    How can I use floats for powers?

    Thanks,

    Florian
  • benc

    #2
    Re: unsupported operand type(s) for ^: 'float' and 'float'

    On Jun 15, 9:21 am, Florian Lindner <Florian.Lind.. .@xgm.dewrote:
    >5.3^4.3
    >
    Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    TypeError: unsupported operand type(s) for ^: 'float' and 'float'
    That operator... I do not think it means what you think it means.
    >>hex(0x1010^0x 0110)
    '0x1100'

    ^ is the bitwise XOR operator. For exponentiation, use **.
    >>5.3**4.3
    1301.3263966398 44

    Hope that helps,
    --Ben

    Comment

    Working...