<script language= "Javascript" >
<!--
function Formatfloat (SRC, POS)
{
Return Math.Round (Src*math.pow (), POS)/math.pow (POS);
}
Alert (Formatfloat ("1212.2323", 2));
-
</SCRIPT>
There are several ways to do this:
var test=11111.111;
Alert (test.tofixed (2));
float data rounded to 2 decimal places;
function To2bits (FLT) {
if (parsefloat (flt) = = FLT)
Return Math.Round (FLT * 100)/100;
to 4 decimal places, return Math.Round (FLT * 10000)/10000;
Else
return 0;
}
ASP retains two decimal places
<%=formatnumber ( -888.888,3,-1,-1,0)%>
(888.900)
The example uses all the parameters of the function FormatNumber ():
The first parameter (-6665.8999) specifies the number to be formatted.
The second parameter (3) specifies the number of digits to display after the decimal point.
The third parameter (-1) specifies whether the leading 0 is displayed.
The fourth parameter (-1) Specifies whether parentheses are used for negative numbers.
The last parameter (0) specifies whether to display separators
JS reserved two decimal places multi-decimal (JavaScript)