Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

odd results using exponent notation in expressions

Contributor ,
Jan 09, 2023 Jan 09, 2023

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? 

TOPICS
Expressions
313
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

LEGEND , Jan 09, 2023 Jan 09, 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 

Translate
Community Expert , Jan 09, 2023 Jan 09, 2023

Instead of ^, use **:

t=0;
(1-t)**2
Translate
LEGEND ,
Jan 09, 2023 Jan 09, 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 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jan 09, 2023 Jan 09, 2023

great, thanks @Mylenium 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 09, 2023 Jan 09, 2023

Instead of ^, use **:

t=0;
(1-t)**2
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jan 09, 2023 Jan 09, 2023
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines