Use of converting JSP Integers to kilobytes (Code instances)

Source: Internet
Author: User

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 ));};

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.