omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    math.pow() problem

    Editorial
    2
    3
    1704
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • misha_turnbull
      misha_turnbull last edited by

      I have a question with the math.pow() function. I was attempting to take the <i>n</i>th root of a number, and there is no function to take roots other than 'sqrt()'. So I tried to use fractional exponents, since 4^(1/2) is the same as taking the square root of 4. I tested this theory in the interpreter, but this is what happened:

      >>>pow(2, (1/2))

      1.0

      >>>pow(4, (1/2))

      1.0

      As you can see, the app is telling me that 2^(1/2) and 4^(1/2) are both equal to 1, which is true of neither. My question is, how do I take <i>n</i>th roots of a number?
      Thank you!

      *sorry for the bad formatting, Im new at this

      1 Reply Last reply Reply Quote 0
      • misha_turnbull
        misha_turnbull last edited by

        Ohh darn this is in the wrong place. I just saw the 'Pythonista' category underneath 'Editorial'....anyone know how to move posts?

        1 Reply Last reply Reply Quote 0
        • omz
          omz last edited by

          The problem is that 1/2 evaluates to 0 because you're dividing two integers, if you use 1.0/2.0 instead, you should get the expected result (1./2 is actually enough).

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Powered by NodeBB Forums | Contributors