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

I create an number up After effects expression from 1000 to 1K but I need to use 2 digit decimal

New Here ,
Jul 10, 2023 Jul 10, 2023

Copy link to clipboard

Copied

Currently I use Point Control to replace slider, when I devide by 1000, all become .00:

numSlider= effect("Point Control")("Point")[0].toFixed(2);
 
if(numSlider>999 && numSlider<1000000){
n = numSlider/1000;
Math.floor(n).toFixed(2)+"k"
}
else if(numSlider>1000000){
m = numSlider/1000000;
Math.floor(m).toFixed(2)+"M"
}
else(numSlider)
TOPICS
Expressions , Scripting

Views

99

Translate

Translate

Report

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
LEGEND ,
Jul 10, 2023 Jul 10, 2023

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

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 ,
Jul 10, 2023 Jul 10, 2023

Copy link to clipboard

Copied

Like this maybe:

numSlider= effect("Point Control")("Point")[0];
dec = numSlider.toFixed(2).substr(-3);
if (numSlider >= 1000000){
  Math.floor(numSlider/1000000) + dec + "M";
}else if (numSlider >= 1000){
  Math.floor(numSlider/1000) + dec + "k";
}else{
  numSlider.toFixed(2);
}

Votes

Translate

Translate

Report

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
New Here ,
Jul 11, 2023 Jul 11, 2023

Copy link to clipboard

Copied

LATEST

Thanks guys for the reply. I found my solution.
I use this script instead:

numSlider= Math.round(effect("Point Control")("Point")[0]);
 
if(numSlider>999 && numSlider<1000000){
n = (numSlider/1000);
digit = 2;
coma= Math.floor(numSlider/Math.pow(10,digit-1))%100;
Math.floor(n)+"."+coma+"k"
}
else if(numSlider>1000000){
m = numSlider/1000000;
digit1 = 5;
coma1= Math.floor(numSlider/Math.pow(10,digit1-1))%100;
Math.floor(m)+"."+coma1+"M"
}
else(numSlider)

 

Votes

Translate

Translate

Report

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