function digits_integer(number, digits, /*optional*/ truncate) {
  if(truncate) number = Math.floor(number).toString();
  else number = Math.round(number).toString();
  if(number.length > digits) return number;
  else while(number.length < digits) number = "0"+number; // add leading zeros
  return number;
}
/** Force a number to an integer with a specific # of digits
 ** @return {string} with leading zeros to reach 'digits' places
 ** 
 ** If the rounded integer has more digits than requested, it will be returned
 ** anyway, as chopping them off the end would change the value by orders of
 ** magnitude, which is almost definitely going to be undesirable.
 */
Force a number to an integer with a specific # of digits
@return {string} with leading zeros to reach 'digits' places

If the rounded integer has more digits than requested, it will be returned
anyway, as chopping them off the end would change the value by orders of
magnitude, which is almost definitely going to be undesirable.
Force a number to an integer with a specific # of digits @return { string } with leading zeros to reach ' digits ' places If the rounded integer has more digits than requested it will be returned anyway as chopping them off the end would change the value by orders of magnitude which is almost definitely going to be undesirable .
function digits_integer(number, digits,  truncate) {
  if(truncate) number = Math.floor(number).toString();
  else number = Math.round(number).toString();
  if(number.length > digits) return number;
  else while(number.length < digits) number = "0"+number; 
  return number;
}
function digits_integer ( number , digits , truncate ) { if ( truncate ) number = Math . floor ( number ) . toString ( ) ; else number = Math . round ( number ) . toString ( ) ; if ( number . length > digits ) return number ; else while ( number . length < digits ) number = "0" + number ; return number ; }
Force a number to an integer with a specific # of digits
 @return {string} with leading zeros to reach 'digits' places
Force a number to an integer with a specific # of digits @return { string } with leading zeros to reach ' digits ' places
/*optional*/ // add leading zeros