-
Fix My Millions – Trying to get numbers to display correctly
I’ve been trying to get this expression to work all day and, frankly, I have a headache. Apologies if I explain this badly; my brain is fried.
I’m working in the latest version of AE CC 2019 and adapted this tutorial to deal with decimals (so, for example, an entry of 1500 returns a result of 1.5K instead of 2K):-
I then further adapted it so it could handle numbers larger than the Slider Control’s limit of 1,000,000 by using an Angle Control as the source instead.
The problem I have is I also need it work with numbers in the billions, but it falls apart in the millions. The highest number I can input before it breaks is 999,949. That returns a result of 999.9K. 999,950 – 999,998 returns 1000.0K. 999,999 makes the display go blank.
1,000,000 dead-on is fine, returning 1M, but anythign between 1,000,000 and 1,099,999 returns 1.0.
If I try to enter 1,000,000,000 (one billion), it returns 1000M.
Hopefully this makes some sort of sense. Open to any suggestions. Please be gentle; I’m quite new at expressions and am well aware I’m probably trying to front up to Usain Bolt before I can walk. ????
numSlider = effect("Angle Control")("Angle")/360;
n = numSlider/1000;
m = numSlider/1000000;
b = numSlider/1000000000;
v = numSlider;
check = v % 1000;
checkMillion = v % 1000000;
checkBillion = v % 1000000000;
//For numbers under 1000
if (numSlider < 1000) numSlider;
//For numbers in the thousands
else if (check == 0 && numSlider < 1000000) Number(n) +"K";
else if (numSlider > 1000 && numSlider < 999999) Number(n).toFixed(1) + "K";
//For numbers in the millions
else if (checkMillion == 0 && numSlider >= 1000000) Number(m) +"M";
else if (numSlider > 1000000 && numSlider < 999999999) Number(m).toFixed(1) + "M";
//For numbers in the billions
else if (checkBillion == 0 && numSlider >= 1000000000) Number(b) +"B";
else if (numSlider > 1000000000) Number(b).toFixed(1) + "B"Some contents or functionalities here are not available due to your cookie preferences!This happens because the functionality/content marked as “Google Youtube” uses cookies that you choosed to keep disabled. In order to view this content or use this functionality, please enable cookies: click here to open your cookie preferences.