1
Discussion | Обсуждение / Re: Number Display form problem?
« on: August 31, 2021, 10:47:36 am »
ok,I have to create wheels for my self.
for achieving the function ,I use the script to finish it(different from old version too),anyone can give me a introduction ?
seems work fine
for achieving the function ,I use the script to finish it(different from old version too),anyone can give me a introduction ?
Code: [Select]
function Pow(base,exp){
if(exp == 0){
return 1;
}else{
var result = 1;
for(i=0;i<exp;i++){
result=result*10;
}
return result;
}
}
function dig_jud(value){
if(value<10&&value>=0){
return true;
}
if(value>=10){
return false;
}
}
function sc_nota(value,percision){
// to make scientific notation
var result;
var digit;
var count=0;
result = value;
var srs;
if(value>=1){
while(result>1)
{
result=result/10;
count++;
}
var exp=count-1;
var temp = Pow(10,exp);
result = value/temp;
digit = count-1;
if(dig_jud(digit)){
srs = numberFormat(result,'f',percision)+"E+0"+digit;
}else{
srs = numberFormat(result,'f',percision)+"E+"+digit;
}
return srs;
}
if(value<1&&value>0){
while(result<1){
result=result*10;
count++;
}
digit=count;
var temp1 = Pow(10, count);
result = value*temp1
if(dig_jud(digit)){
srs = numberFormat(result,'f',percision)+"E-0"+digit;
}else{
srs = numberFormat(result,'f',percision)+"E-"+digit;
}
return srs;
}
if(value<0){
return "NULL"
}
}
seems work fine