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

Discussion in 'Python' started by Florian Lindner, Jun 15, 2007.

  1. 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
    Florian Lindner, Jun 15, 2007
    #1
    1. Advertising

  2. Florian Lindner

    benc Guest

    On Jun 15, 9:21 am, Florian Lindner <> wrote:
    > >>> 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^0x0110)

    '0x1100'

    ^ is the bitwise XOR operator. For exponentiation, use **.

    >>> 5.3**4.3

    1301.326396639844

    Hope that helps,
    --Ben
    benc, Jun 15, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Martin Koekenberg
    Replies:
    3
    Views:
    1,311
    Martin Koekenberg
    Aug 26, 2004
  2. Brett C.
    Replies:
    2
    Views:
    2,852
    Martin Koekenberg
    Aug 30, 2004
  3. Rakesh
    Replies:
    3
    Views:
    6,306
    Rakesh
    Mar 30, 2005
  4. Francesc Segura
    Replies:
    0
    Views:
    488
    Francesc Segura
    Jun 10, 2011
  5. Francesc Segura
    Replies:
    6
    Views:
    3,298
    Thomas Rachel
    Jun 12, 2011
Loading...

Share This Page