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

Math.round but with 2 decimals!

Community Beginner ,
Nov 30, 2022 Nov 30, 2022

Hello, I am trying to make this expression to show in percentage (%) and with 2 decimals.

Math.round(thisComp.layer("Shape Layer 1").effect("Slider Control 1")("ADBE Slider Control-0001")/100*comp("09 Infographic 19").layer("Data Settings").effect("Data 1")("ADBE Slider Control-0001"))

I am trying to do it with the " toFixed(2) " but I m having no luck.
Any suggestions?

Thanks in advance

TOPICS
Error or problem , Expressions , How to
2.0K
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 1 Correct answer

Community Expert , Nov 30, 2022 Nov 30, 2022

I think you just need to append this to what you have:

.toFixed(2) + "%"
Translate
LEGEND ,
Nov 30, 2022 Nov 30, 2022

Multiply the input value by 100, round it, divide the value withe the same number. Oldest trick in the book. Simple math.

 

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 Beginner ,
Nov 30, 2022 Nov 30, 2022

Hello and thank you for you answer.
The frustrating thing is that I know how to do math on paper or with a calculator but I have no clue how to do it with code.
What you said makes perfect sense but I don't know where or how to intergrade it in the expression 😕
Can you help? 

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 ,
Nov 30, 2022 Nov 30, 2022

I think you just need to append this to what you have:

.toFixed(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
Community Beginner ,
Nov 30, 2022 Nov 30, 2022

Great! Thank you very much. I added what you said at the end of the expression and gave me the .00% I wanted 🙂
You think it can give me any other result exept .00 all the time? Now it's showing 1.00%, 2.00%, 3.00% ......99.00%. Can I get a number like 3.36% for example and not just .00?

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 Beginner ,
Nov 30, 2022 Nov 30, 2022
LATEST

Nevermind. I removed the Math.round from the begining and it counts everything now!
See? I am learning! 😛


Thank you guys s much 🙂

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