Skip to main content
Known Participant
January 9, 2023
Answered

odd results using exponent notation in expressions

  • January 9, 2023
  • 2 replies
  • 520 views

Writing an expression to control the scale of a layer. 

I'm using variable t to represent a value between 0 and 1.

At t=0, the expression:

(1-t)^2

returns the number 3. The expected value is 1. 

Meanhile, (1-t)*(1-t) returns the correct value of 1. 

This makes me think I am denoting exponents incorrectly altogther-- that the carrot "^" is NOT how you represent "to the power of" in AE expressions. 

 

Can someone explain what's going on here? 

This topic has been closed for replies.
Correct answer Dan Ebberts

Instead of ^, use **:

t=0;
(1-t)**2

2 replies

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
January 9, 2023

Instead of ^, use **:

t=0;
(1-t)**2
Known Participant
January 9, 2023

Ahh of course! Forgot to try that. That's how it works in Python too. Thanks Dan. 

Mylenium
Legend
January 9, 2023

Correct. Exponents are Math.pow(base,exponent). Nothing specific to AE, general JavaScript math and there are enough web sites out there that explain it. The ^ on the other hand would be a special operator to enforce bytewise processing, which isn't even relevant for AE, only for certain web engines.

 

Mylenium 

Known Participant
January 9, 2023

great, thanks @Mylenium