lib/std/string.cc
// Helper function for converting decimal numbers to strings.
Helper function for converting decimal numbers to strings.
Helper function for converting decimal numbers to strings .
int convert_decimal(char *dest, int32_t to_print) {
  int written = 0;
  int index = 9;
  uint8_t digits[10] = {0};
  if (to_print < 0) {
    dest[written] = '-';
    written++;
    to_print *= -1;
  } else if (!to_print) {
    dest[written] = '0';
    return 1;
  }
  while (to_print) {
    digits[index] = to_print % 10;
    to_print /= 10;
    index--;
  }
  index++;
  for (index; index < 10; index++) {
    dest[written] = hexits[digits[index]];
    written++;
  }
  return written;
}
int convert_decimal ( char * dest , int32_t to_print ) { int written = 0 ; int index = 9 ; uint8_t digits [ 10 ] = { 0 } ; if ( to_print < 0 ) { dest [ written ] = ' ' ; written ++ ; to_print *= -1 ; } else if ( ! to_print ) { dest [ written ] = ' ' ; return 1 ; } while ( to_print ) { digits [ index ] = to_print % 10 ; to_print /= 10 ; index -- ; } index ++ ; for ( index ; index < 10 ; index ++ ) { dest [ written ] = hexits [ digits [ index ] ] ; written ++ ; } return written ; }
Helper function for converting decimal numbers to strings.
Helper function for converting decimal numbers to strings .