function
getRound(num,digits=2) {
let temp=num;
num=Math.round(num*(Math.pow(10,(digits+1))))/(Math.pow(10,(digits+1)));
let tm
function
getRound(num,digits=2) {
num=Math.round(num*(Math.pow(10,(digits))));
num=num/(Math.pow(10,digits));
let tempstr=String(num);
let temp=tempstr.indexOf(
"."
);
if
(digits==0){
return
parseInt(tempstr);
}
else
{
if
(temp>=0){
tempstr.slice(temp,temp+digits);
for
(let i=temp+1;i<digits+temp+1;i++){ <=
""
div=
""
>
if
(tempstr.charAt(i)==undefined||tempstr.charAt(i)==
null
||tempstr.charAt(i)==
""
){
tempstr+=
'0'
}
}
}
else
{
tempstr+=
'.'
;
for
(let i=0;i<digits;i++){ <=
""
div=
""
>
tempstr+=
'0'
;
}
}
return
tempstr
}
}pStr=String(num);
let tmpArr=tmpStr.split(
"."
);
if
(tmpArr.length==1){
if
(digits==0){
return
num
}
else
{
let str=
''
;
for
(let i=0;i<digits;i++){ <=
""
div=
""
>
str+=
'0'
;
}
return
num+
'.'
+str;
}
}
else
if
(tmpArr.length==2){
if
(digits==0){
return
Math.round(temp)
}
else
{
let tmp=String(tmpArr[1]);
if
(tmp.length>digits){
tmp=tmp.slice(0,digits+1);
if
(tmp>digits){
tmp=Number(tmp)/10;
}
tmp=parseInt(tmp);
}
let str=String(tmp);
if
(str.length<digits){ <=
""
div=
""
>
for
(let i=str.length;i<digits;i++){ <=
""
div=
""
>
str+=
'0'
;
}
}
tmp=tmpArr[0]+
'.'
+str;
return
tmp;
}
}
}