...mathmatical calculation correction on numbershorten

This commit is contained in:
bluesaxman 2021-06-18 15:27:37 -06:00
parent b05415cb29
commit ee7a5b161e

View File

@ -88,13 +88,13 @@ function titledContainer (ParentID,ID,Class,Element,Position,Title) {
function numberShorten (Value,Accuricy) {
var level = 0;
var number = "number" == typeof Value ? Value : 0;
var places = "number" == typeof Accuricy ? Accuricy : 3;
var places = "number" == typeof Accuricy ? Math.pow(10,Accuricy) : 1000;
var unit = ["","k","M","B","T","q","Q","s","S","O","N","d","Ud","Dd","Td","qd","Qd","sd","Sd","Od","Nd","v","Uv","Dv","Tv","qv","Qv","sv","Sv","Ov","Nv","t","Ut","Dt","Tt","qt","Qt","st","St","Ot","Nv","c","uc","dc","Tc","Dc","Uc","vc","Sc","Oc","Nc","STOP"];
while (999<number) {
level++;
number = Math.round(number)/1000;
}
return (Math.floor(number*(places*10))/(places*10))+unit[level];
return (Math.floor(number*places)/places)+unit[level];
}
function buttonAdd (ParentID,ID,Label,Action,Class,Element) {