src/backend/utils/adt/numutils.c
char *
pg_ultostr_zeropad(char *str, uint32 value, int32 minwidth)
{
	int			len;

	Assert(minwidth > 0);

	if (value < 100 && minwidth == 2)	/* Short cut for common case */
	{
		memcpy(str, DIGIT_TABLE + value * 2, 2);
		return str + 2;
	}

	len = pg_ultoa_n(value, str);
	if (len >= minwidth)
		return str + len;

	memmove(str + minwidth - len, str, len);
	memset(str, '0', minwidth - len);
	return str + minwidth;
}
/*
 * pg_ultostr_zeropad
 *		Converts 'value' into a decimal string representation stored at 'str'.
 *		'minwidth' specifies the minimum width of the result; any extra space
 *		is filled up by prefixing the number with zeros.
 *
 * Returns the ending address of the string result (the last character written
 * plus 1).  Note that no NUL terminator is written.
 *
 * The intended use-case for this function is to build strings that contain
 * multiple individual numbers, for example:
 *
 *	str = pg_ultostr_zeropad(str, hours, 2);
 *	*str++ = ':';
 *	str = pg_ultostr_zeropad(str, mins, 2);
 *	*str++ = ':';
 *	str = pg_ultostr_zeropad(str, secs, 2);
 *	*str = '\0';
 *
 * Note: Caller must ensure that 'str' points to enough memory to hold the
 * result.
 */
pg_ultostr_zeropad
Converts 'value' into a decimal string representation stored at 'str'.
'minwidth' specifies the minimum width of the result; any extra space
is filled up by prefixing the number with zeros.

Returns the ending address of the string result (the last character written
plus 1).  Note that no NUL terminator is written.

The intended use-case for this function is to build strings that contain
multiple individual numbers, for example.



Caller must ensure that 'str' points to enough memory to hold the
result.
pg_ultostr_zeropad Converts ' value ' into a decimal string representation stored at ' str ' . ' minwidth ' specifies the minimum width of the result ; any extra space is filled up by prefixing the number with zeros . Returns the ending address of the string result ( the last character written plus 1 ) . Note that no NUL terminator is written . The intended use - case for this function is to build strings that contain multiple individual numbers for example . Caller must ensure that ' str ' points to enough memory to hold the result .
char *
pg_ultostr_zeropad(char *str, uint32 value, int32 minwidth)
{
	int			len;
	Assert(minwidth > 0);
	if (value < 100 && minwidth == 2)	
	{
		memcpy(str, DIGIT_TABLE + value * 2, 2);
		return str + 2;
	}
	len = pg_ultoa_n(value, str);
	if (len >= minwidth)
		return str + len;
	memmove(str + minwidth - len, str, len);
	memset(str, '0', minwidth - len);
	return str + minwidth;
}
char * pg_ultostr_zeropad ( char * str , uint32 value , int32 minwidth ) { int len ; Assert ( minwidth > 0 ) ; if ( value < 100 && minwidth == 2 ) { memcpy ( str , DIGIT_TABLE + value * 2 , 2 ) ; return str + 2 ; } len = pg_ultoa_n ( value , str ) ; if ( len >= minwidth ) return str + len ; memmove ( str + minwidth - len , str , len ) ; memset ( str , ' ' , minwidth - len ) ; return str + minwidth ; }
pg_ultostr_zeropad
              Converts 'value' into a decimal string representation stored at 'str'.
pg_ultostr_zeropad Converts ' value ' into a decimal string representation stored at ' str ' .
/* Short cut for common case */