nl_tokens: Format a number into a string
pl_tokens: function formatNumber ( number , pattern , groupSep , decimalSep , fractionSize ) { if ( ! ( isString ( number ) || isNumber ( number ) ) || isNaN ( <mask> ) ) return '' ; var isInfinity = ! isFinite ( number ) ; var isZero = false ; var numStr = Math . abs ( number ) + '' , formattedText = '' , parsedNumber ; if ( isInfinity ) { formattedText = '\u221e' ; } else { parsedNumber = parse ( numStr ) ; roundNumber ( parsedNumber , fractionSize , pattern . minFrac , pattern . maxFrac ) ; var digits = parsedNumber . d ; var integerLen = parsedNumber . i ; var exponent = parsedNumber . e ; var decimals = [ ] ; isZero = digits . reduce ( function ( isZero , d ) { return isZero && ! d ; } , true ) ; // pad zeros for small numbers while ( integerLen < 0 ) { digits . unshift ( 0 ) ; integerLen ++ ; } // extract decimals digits if ( integerLen > 0 ) { decimals = digits . splice ( integerLen , digits . length ) ; } else { decimals = digits ; digits = [ 0 ] ; } // format the integer digits with grouping separators var groups = [ ] ; if ( digits . length >= pattern . lgSize ) { groups . unshift ( digits . splice ( - pattern . lgSize , digits . length ) . join ( '' ) ) ; } while ( digits . length > pattern . gSize ) { groups . unshift ( digits . splice ( - pattern . gSize , digits . length ) . join ( '' ) ) ; } if ( digits . length ) { groups . unshift ( digits . join ( '' ) ) ; } formattedText = groups . join ( groupSep ) ; // append the decimal digits if ( decimals . length ) { formattedText += decimalSep + decimals . join ( '' ) ; } if ( exponent ) { formattedText += 'e+' + exponent ; } } if ( number < 0 && ! isZero ) { return pattern . negPre + formattedText + pattern . negSuf ; } else { return pattern . posPre + formattedText + pattern . posSuf ; } }