function autoRound(iv, settings) { /** value to string */
        iv = (iv === '') ? '0' : iv.toString();
        if (settings.mRound === 'N05' || settings.mRound === 'U05' || settings.mRound === 'D05') {
            iv = (settings.mRound === 'N05') ? (Math.round(iv * 20) / 20).toString() : (settings.mRound === 'U05') ? (Math.ceil(iv * 20) / 20).toString() : (Math.floor(iv * 20) / 20).toString();
            return (iv.indexOf('.') === -1) ? iv + '.00' : (iv.length - iv.indexOf('.') < 3) ? iv + '0' : iv;
        }
        var ivRounded = '',
            i = 0,
            nSign = '',
            rDec = (typeof(settings.aPad) === 'boolean' || settings.aPad === null) ? (settings.aPad ? settings.mDec : 0) : Number(settings.aPad);
        var truncateZeros = function (ivRounded) { /** truncate not needed zeros */
            var regex = rDec === 0 ? (/(\.(?:\d*[1-9])?)0*$/) : rDec === 1 ? (/(\.\d(?:\d*[1-9])?)0*$/) : new RegExp('(\\.\\d{' + rDec + '}(?:\\d*[1-9])?)0*');
            ivRounded = ivRounded.replace(regex, '$1'); /** If there are no decimal places, we don't need a decimal point at the end */
            if (rDec === 0) {
                ivRounded = ivRounded.replace(/\.$/, '');
            }
            return ivRounded;
        };
        if (iv.charAt(0) === '-') { /** Checks if the iv (input Value)is a negative value */
            nSign = '-';
            iv = iv.replace('-', ''); /** removes the negative sign will be added back later if required */
        }
        if (!iv.match(/^\d/)) { /** append a zero if first character is not a digit (then it is likely to be a dot)*/
            iv = '0' + iv;
        }
        if (nSign === '-' && Number(iv) === 0) { /** determines if the value is zero - if zero no negative sign */
            nSign = '';
        }
        if ((Number(iv) > 0 && settings.lZero !== 'keep') || (iv.length > 0 && settings.lZero === 'allow')) { /** trims leading zero's if needed */
            iv = iv.replace(/^0*(\d)/, '$1');
        }
        var dPos = iv.lastIndexOf('.'),
            /** virtual decimal position */
            vdPos = (dPos === -1) ? iv.length - 1 : dPos,
            /** checks decimal places to determine if rounding is required */
            cDec = (iv.length - 1) - vdPos; /** check if no rounding is required */
        if (cDec <= settings.mDec) {
            ivRounded = iv; /** check if we need to pad with zeros */
            if (cDec < rDec) {
                if (dPos === -1) {
                    //ivRounded += '.';
                    ivRounded += settings.aDec;
                }
                var zeros = '000000';
                while (cDec < rDec) {
                    zeros = zeros.substring(0, rDec - cDec);
                    ivRounded += zeros;
                    cDec += zeros.length;
                }
            } else if (cDec > rDec) {
                ivRounded = truncateZeros(ivRounded);
            } else if (cDec === 0 && rDec === 0) {
                ivRounded = ivRounded.replace(/\.$/, '');
            }
            return (Number(ivRounded) === 0) ? ivRounded : nSign + ivRounded;
        } /** rounded length of the string after rounding */
        var rLength = dPos + settings.mDec,
            tRound = Number(iv.charAt(rLength + 1)),
            ivArray = iv.substring(0, rLength + 1).split(''),
            odd = (iv.charAt(rLength) === '.') ? (iv.charAt(rLength - 1) % 2) : (iv.charAt(rLength) % 2);
        /*jslint white: true*/
        if ((tRound > 4 && settings.mRound === 'S') || /**                      Round half up symmetric */
            (tRound > 4 && settings.mRound === 'A' && nSign === '') || /**      Round half up asymmetric positive values */
            (tRound > 5 && settings.mRound === 'A' && nSign === '-') || /**     Round half up asymmetric negative values */
            (tRound > 5 && settings.mRound === 's') || /**                      Round half down symmetric */
            (tRound > 5 && settings.mRound === 'a' && nSign === '') || /**      Round half down asymmetric positive values */
            (tRound > 4 && settings.mRound === 'a' && nSign === '-') || /**     Round half down asymmetric negative values */
            (tRound > 5 && settings.mRound === 'B') || /**                      Round half even "Banker's Rounding" */
            (tRound === 5 && settings.mRound === 'B' && odd === 1) || /**       Round half even "Banker's Rounding" */
            (tRound > 0 && settings.mRound === 'C' && nSign === '') || /**      Round to ceiling toward positive infinite */
            (tRound > 0 && settings.mRound === 'F' && nSign === '-') || /**     Round to floor toward negative infinite */
            (tRound > 0 && settings.mRound === 'U')) { /**                      Round up away from zero */
            /*jslint white: false*/
            for (i = (ivArray.length - 1); i >= 0; i -= 1) { /** Round up the last digit if required, and continue until no more 9's are found */
                if (ivArray[i] !== '.') {
                    ivArray[i] = +ivArray[i] + 1;
                    if (ivArray[i] < 10) {
                        break;
                    }
                    if (i > 0) {
                        ivArray[i] = '0';
                    }
                }
            }
        }
        ivArray = ivArray.slice(0, rLength + 1); /** Reconstruct the string, converting any 10's to 0's */
        ivRounded = truncateZeros(ivArray.join('')); /** return rounded value */
        return (Number(ivRounded) === 0) ? ivRounded : nSign + ivRounded;
    }
/**
     * round number after setting by pasting or $().autoNumericSet()
     * private function for round the number
     * please note this handled as text - JavaScript math function can return inaccurate values
     * also this offers multiple rounding methods that are not easily accomplished in JavaScript
     */
round number after setting by pasting or $().autoNumericSet()
private function for round the number
please note this handled as text - JavaScript math function can return inaccurate values
also this offers multiple rounding methods that are not easily accomplished in JavaScript
round number after setting by pasting or $ () . autoNumericSet () private function for round the number please note this handled as text - JavaScript math function can return inaccurate values also this offers multiple rounding methods that are not easily accomplished in JavaScript
function autoRound(iv, settings) { 
        iv = (iv === '') ? '0' : iv.toString();
        if (settings.mRound === 'N05' || settings.mRound === 'U05' || settings.mRound === 'D05') {
            iv = (settings.mRound === 'N05') ? (Math.round(iv * 20) / 20).toString() : (settings.mRound === 'U05') ? (Math.ceil(iv * 20) / 20).toString() : (Math.floor(iv * 20) / 20).toString();
            return (iv.indexOf('.') === -1) ? iv + '.00' : (iv.length - iv.indexOf('.') < 3) ? iv + '0' : iv;
        }
        var ivRounded = '',
            i = 0,
            nSign = '',
            rDec = (typeof(settings.aPad) === 'boolean' || settings.aPad === null) ? (settings.aPad ? settings.mDec : 0) : Number(settings.aPad);
        var truncateZeros = function (ivRounded) { 
            var regex = rDec === 0 ? (/(\.(?:\d*[1-9])?)0*$/) : rDec === 1 ? (/(\.\d(?:\d*[1-9])?)0*$/) : new RegExp('(\\.\\d{' + rDec + '}(?:\\d*[1-9])?)0*');
            ivRounded = ivRounded.replace(regex, '$1'); 
            if (rDec === 0) {
                ivRounded = ivRounded.replace(/\.$/, '');
            }
            return ivRounded;
        };
        if (iv.charAt(0) === '-') { 
            nSign = '-';
            iv = iv.replace('-', ''); 
        }
        if (!iv.match(/^\d/)) { 
            iv = '0' + iv;
        }
        if (nSign === '-' && Number(iv) === 0) { 
            nSign = '';
        }
        if ((Number(iv) > 0 && settings.lZero !== 'keep') || (iv.length > 0 && settings.lZero === 'allow')) { 
            iv = iv.replace(/^0*(\d)/, '$1');
        }
        var dPos = iv.lastIndexOf('.'),
            vdPos = (dPos === -1) ? iv.length - 1 : dPos,
            cDec = (iv.length - 1) - vdPos; 
        if (cDec <= settings.mDec) {
            ivRounded = iv; 
            if (cDec < rDec) {
                if (dPos === -1) {
                    ivRounded += settings.aDec;
                }
                var zeros = '000000';
                while (cDec < rDec) {
                    zeros = zeros.substring(0, rDec - cDec);
                    ivRounded += zeros;
                    cDec += zeros.length;
                }
            } else if (cDec > rDec) {
                ivRounded = truncateZeros(ivRounded);
            } else if (cDec === 0 && rDec === 0) {
                ivRounded = ivRounded.replace(/\.$/, '');
            }
            return (Number(ivRounded) === 0) ? ivRounded : nSign + ivRounded;
        } 
        var rLength = dPos + settings.mDec,
            tRound = Number(iv.charAt(rLength + 1)),
            ivArray = iv.substring(0, rLength + 1).split(''),
            odd = (iv.charAt(rLength) === '.') ? (iv.charAt(rLength - 1) % 2) : (iv.charAt(rLength) % 2);
        if ((tRound > 4 && settings.mRound === 'S') || 
            (tRound > 4 && settings.mRound === 'A' && nSign === '') || 
            (tRound > 5 && settings.mRound === 'A' && nSign === '-') || 
            (tRound > 5 && settings.mRound === 's') || 
            (tRound > 5 && settings.mRound === 'a' && nSign === '') || 
            (tRound > 4 && settings.mRound === 'a' && nSign === '-') || 
            (tRound > 5 && settings.mRound === 'B') || 
            (tRound === 5 && settings.mRound === 'B' && odd === 1) || 
            (tRound > 0 && settings.mRound === 'C' && nSign === '') || 
            (tRound > 0 && settings.mRound === 'F' && nSign === '-') || 
            (tRound > 0 && settings.mRound === 'U')) { 
            for (i = (ivArray.length - 1); i >= 0; i -= 1) { 
                if (ivArray[i] !== '.') {
                    ivArray[i] = +ivArray[i] + 1;
                    if (ivArray[i] < 10) {
                        break;
                    }
                    if (i > 0) {
                        ivArray[i] = '0';
                    }
                }
            }
        }
        ivArray = ivArray.slice(0, rLength + 1); 
        ivRounded = truncateZeros(ivArray.join('')); 
        return (Number(ivRounded) === 0) ? ivRounded : nSign + ivRounded;
    }
function autoRound ( iv , settings ) { iv = ( iv === '' ) ? '0' : iv . toString ( ) ; if ( settings . mRound === 'N05' || settings . mRound === 'U05' || settings . mRound === 'D05' ) { iv = ( settings . mRound === 'N05' ) ? ( Math . round ( iv * 20 ) / 20 ) . toString ( ) : ( settings . mRound === 'U05' ) ? ( Math . ceil ( iv * 20 ) / 20 ) . toString ( ) : ( Math . floor ( iv * 20 ) / 20 ) . toString ( ) ; return ( iv . indexOf ( '.' ) === - 1 ) ? iv + '.00' : ( iv . length - iv . indexOf ( '.' ) < 3 ) ? iv + '0' : iv ; } var ivRounded = '' , i = 0 , nSign = '' , rDec = ( typeof ( settings . aPad ) === 'boolean' || settings . aPad === null ) ? ( settings . aPad ? settings . mDec : 0 ) : Number ( settings . aPad ) ; var truncateZeros = function ( ivRounded ) { var regex = rDec === 0 ? ( / (\.(?:\d*[1-9])?)0*$ / ) : rDec === 1 ? ( / (\.\d(?:\d*[1-9])?)0*$ / ) : new RegExp ( '(\\.\\d{' + rDec + '}(?:\\d*[1-9])?)0*' ) ; ivRounded = ivRounded . replace ( regex , '$1' ) ; if ( rDec === 0 ) { ivRounded = ivRounded . replace ( / \.$ / , '' ) ; } return ivRounded ; } ; if ( iv . charAt ( 0 ) === '-' ) { nSign = '-' ; iv = iv . replace ( '-' , '' ) ; } if ( ! iv . match ( / ^\d / ) ) { iv = '0' + iv ; } if ( nSign === '-' && Number ( iv ) === 0 ) { nSign = '' ; } if ( ( Number ( iv ) > 0 && settings . lZero !== 'keep' ) || ( iv . length > 0 && settings . lZero === 'allow' ) ) { iv = iv . replace ( / ^0*(\d) / , '$1' ) ; } var dPos = iv . lastIndexOf ( '.' ) , vdPos = ( dPos === - 1 ) ? iv . length - 1 : dPos , cDec = ( iv . length - 1 ) - vdPos ; if ( cDec <= settings . mDec ) { ivRounded = iv ; if ( cDec < rDec ) { if ( dPos === - 1 ) { ivRounded += settings . aDec ; } var zeros = '000000' ; while ( cDec < rDec ) { zeros = zeros . substring ( 0 , rDec - cDec ) ; ivRounded += zeros ; cDec += zeros . length ; } } else if ( cDec > rDec ) { ivRounded = truncateZeros ( ivRounded ) ; } else if ( cDec === 0 && rDec === 0 ) { ivRounded = ivRounded . replace ( / \.$ / , '' ) ; } return ( Number ( ivRounded ) === 0 ) ? ivRounded : nSign + ivRounded ; } var rLength = dPos + settings . mDec , tRound = Number ( iv . charAt ( rLength + 1 ) ) , ivArray = iv . substring ( 0 , rLength + 1 ) . split ( '' ) , odd = ( iv . charAt ( rLength ) === '.' ) ? ( iv . charAt ( rLength - 1 ) % 2 ) : ( iv . charAt ( rLength ) % 2 ) ; if ( ( tRound > 4 && settings . mRound === 'S' ) || ( tRound > 4 && settings . mRound === 'A' && nSign === '' ) || ( tRound > 5 && settings . mRound === 'A' && nSign === '-' ) || ( tRound > 5 && settings . mRound === 's' ) || ( tRound > 5 && settings . mRound === 'a' && nSign === '' ) || ( tRound > 4 && settings . mRound === 'a' && nSign === '-' ) || ( tRound > 5 && settings . mRound === 'B' ) || ( tRound === 5 && settings . mRound === 'B' && odd === 1 ) || ( tRound > 0 && settings . mRound === 'C' && nSign === '' ) || ( tRound > 0 && settings . mRound === 'F' && nSign === '-' ) || ( tRound > 0 && settings . mRound === 'U' ) ) { for ( i = ( ivArray . length - 1 ) ; i >= 0 ; i -= 1 ) { if ( ivArray [ i ] !== '.' ) { ivArray [ i ] = + ivArray [ i ] + 1 ; if ( ivArray [ i ] < 10 ) { break ; } if ( i > 0 ) { ivArray [ i ] = '0' ; } } } } ivArray = ivArray . slice ( 0 , rLength + 1 ) ; ivRounded = truncateZeros ( ivArray . join ( '' ) ) ; return ( Number ( ivRounded ) === 0 ) ? ivRounded : nSign + ivRounded ; }
round number after setting by pasting or $().autoNumericSet()
 private function for round the number
 please note this handled as text - JavaScript math function can return inaccurate values
 also this offers multiple rounding methods that are not easily accomplished in JavaScript
round number after setting by pasting or $ () . autoNumericSet () private function for round the number please note this handled as text - JavaScript math function can return inaccurate values also this offers multiple rounding methods that are not easily accomplished in JavaScript
/** value to string */ /** truncate not needed zeros */ /** If there are no decimal places, we don't need a decimal point at the end */ /** Checks if the iv (input Value)is a negative value */ /** removes the negative sign will be added back later if required */ /** append a zero if first character is not a digit (then it is likely to be a dot)*/ /** determines if the value is zero - if zero no negative sign */ /** trims leading zero's if needed */ /** virtual decimal position */ /** checks decimal places to determine if rounding is required */ /** check if no rounding is required */ /** check if we need to pad with zeros */ //ivRounded += '.'; /** rounded length of the string after rounding */ /*jslint white: true*/ /**                      Round half up symmetric */ /**      Round half up asymmetric positive values */ /**     Round half up asymmetric negative values */ /**                      Round half down symmetric */ /**      Round half down asymmetric positive values */ /**     Round half down asymmetric negative values */ /**                      Round half even "Banker's Rounding" */ /**       Round half even "Banker's Rounding" */ /**      Round to ceiling toward positive infinite */ /**     Round to floor toward negative infinite */ /**                      Round up away from zero */ /*jslint white: false*/ /** Round up the last digit if required, and continue until no more 9's are found */ /** Reconstruct the string, converting any 10's to 0's */ /** return rounded value */