Jvasloud computing retains one or two decimal places. It has four different effects and is very suitable for mall websites. For more information, see
1. Clear the decimal point:
The Code is as follows:
Function returnFloat0 (value ){
Value = Math. round (parseFloat (value ));
Return value;
}
2. retain one decimal point:
The Code is as follows:
Function returnFloat1 (value ){
Value = Math. round (parseFloat (value) * 10)/10;
If (value. toString (). indexOf (".") <0 ){
Value = value. toString () + ". 0 ";
}
Return value;
}
3. retain two decimal places
The Code is as follows:
Function returnFloat2 (value ){
Value = Math. round (parseFloat (value) * 100)/100;
If (value. toString (). indexOf (".") <0 ){
Value = value. toString () + ". 00 ";
}
Return value;
}
4. retain two decimal places. one decimal point is automatically filled with zero.
The Code is as follows:
Function returnFloat3 (value ){
Value = Math. round (parseFloat (value) * 100)/100;
Var xsd = value. toString (). split (".");
// Ext. log (xsd. length );
If (xsd. length = 1 ){
Value = value. toString () + ". 00 ";
Return value;
}
If (xsd. length> 1 ){
If (xsd [1]. length <2 ){
Value = value. toString () + "0 ";
}
Return value;
}
}