Use of converting JSP Integers to kilobytes (Code instances)
Use of converting JSP Integers to kilobytes (code example)
// Use the function formatNumberToStr (mVal, iAccuracy) {var fTmp = 0.00; // temporary variable var iFra = 0; // var iInt = 0 in the fractional part; // integer part var aBuf = new Array (); // output cache var bPositive = true; // Save the positive and negative values mark (true: Positive) /*** output a fixed-length string, not enough fill 0 * <li> closure function </li> * @ param int iVal value * @ param int iLen output length */function funZero (iVal, iLen) {var sTmp = iVal. toString (); var sBuf = new Array (); for (var I = 0, iLoop = iLen-sTmp.length; I <iLoop; I ++) SBuf. push ('0'); sBuf. push (sTmp); return sBuf. join ('') ;}; if (typeof (iAccuracy) === 'undefined') iAccuracy = 2; bPositive = (mVal> = 0 ); // retrieve the plus and minus signs fTmp = (isNaN (fTmp = parseFloat (mVal )))? 0: Math. abs (fTmp); // force convert to absolute value number floating point // all content is processed using positive number rules iInt = parseInt (fTmp ); // separate integer part iFra = parseInt (fTmp-iInt) * Math. pow (10, iAccuracy) + 0.5); // separate the fractional part (rounding) do {aBuf. unshift (funZero (iInt % 1000, 3);} while (iInt = parseInt (iInt/1000); aBuf [0] = parseInt (aBuf [0]). toString (); // remove the leading 0 return (bPositive )? '': '-') + ABuf. join (',') + '.' + (0 = iFra )? '00': funZero (iFra, iAccuracy ));};