Python Forum
Difference between math.pow and **
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Difference between math.pow and **
#6
Additional bit of information from Python documentation which could help to avoid some pitfalls down the road:

Quote:The power operator binds more tightly than unary operators on its left; it binds less tightly than unary operators on its right. /../

Thus, in an unparenthesized sequence of power and unary operators, the operators are evaluated from right to left (this does not constrain the evaluation order for the operands): -1**2 results in -1.
alloydog likes this post
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
Difference between math.pow and ** - by alloydog - Dec-29-2020, 07:37 PM
RE: Difference between math.pow and ** - by jjc385 - Dec-29-2020, 07:55 PM
RE: Difference between math.pow and ** - by perfringo - Dec-30-2020, 01:44 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  math.log versus math.log10 stevendaprano 10 2,462 May-23-2022, 08:59 PM
Last Post: jefsummers
  Why getting ValueError : Math domain error in trig. function, math.asin() ? jahuja73 3 3,812 Feb-24-2021, 05:09 PM
Last Post: bowlofred

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020