src/player-birth.c
static int int_to_roman(int n, char *roman, size_t bufsize)
{
	/* Roman symbols */
	char roman_symbol_labels[13][3] =
		{"M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX",
		 "V", "IV", "I"};
	int  roman_symbol_values[13] =
		{1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1};

	/* Clear the roman numeral buffer */
	roman[0] = '\0';

	/* Roman numerals have no zero or negative numbers */
	if (n < 1)
		return 0;

	/* Build the roman numeral in the buffer */
	while (n > 0) {
		int i = 0;

		/* Find the largest possible roman symbol */
		while (n < roman_symbol_values[i])
			i++;

		/* No room in buffer, so abort */
		if (strlen(roman) + strlen(roman_symbol_labels[i]) + 1
			> bufsize)
			break;

		/* Add the roman symbol to the buffer */
		my_strcat(roman, roman_symbol_labels[i], bufsize);

		/* Decrease the value of the arabic numeral */
		n -= roman_symbol_values[i];
	}

	/* Ran out of space and aborted */
	if (n > 0) {
		/* Clean up and return */
		roman[0] = '\0';

		return 0;
	}

	return 1;
}
/**
 * Converts an arabic numeral (int) to a roman numeral (char *).
 *
 * An arabic numeral is accepted in parameter `n`, and the corresponding
 * upper-case roman numeral is placed in the parameter `roman`.  The
 * length of the buffer must be passed in the `bufsize` parameter.  When
 * there is insufficient room in the buffer, or a roman numeral does not
 * exist (e.g. non-positive integers) a value of 0 is returned and the
 * `roman` buffer will be the empty string.  On success, a value of 1 is
 * returned and the zero-terminated roman numeral is placed in the
 * parameter `roman`.
 */
Converts an arabic numeral (int) to a roman numeral (char *).
An arabic numeral is accepted in parameter `n`, and the corresponding
upper-case roman numeral is placed in the parameter `roman`.  The
length of the buffer must be passed in the `bufsize` parameter.  When
there is insufficient room in the buffer, or a roman numeral does not
exist  a value of 0 is returned and the
`roman` buffer will be the empty string.  On success, a value of 1 is
returned and the zero-terminated roman numeral is placed in the
parameter `roman`.
Converts an arabic numeral ( int ) to a roman numeral ( char * ) . An arabic numeral is accepted in parameter ` n ` and the corresponding upper - case roman numeral is placed in the parameter ` roman ` . The length of the buffer must be passed in the ` bufsize ` parameter . When there is insufficient room in the buffer or a roman numeral does not exist a value of 0 is returned and the ` roman ` buffer will be the empty string . On success a value of 1 is returned and the zero - terminated roman numeral is placed in the parameter ` roman ` .
static int int_to_roman(int n, char *roman, size_t bufsize)
{
	char roman_symbol_labels[13][3] =
		{"M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX",
		 "V", "IV", "I"};
	int  roman_symbol_values[13] =
		{1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1};
	roman[0] = '\0';
	if (n < 1)
		return 0;
	while (n > 0) {
		int i = 0;
		while (n < roman_symbol_values[i])
			i++;
		if (strlen(roman) + strlen(roman_symbol_labels[i]) + 1
			> bufsize)
			break;
		my_strcat(roman, roman_symbol_labels[i], bufsize);
		n -= roman_symbol_values[i];
	}
	if (n > 0) {
		roman[0] = '\0';
		return 0;
	}
	return 1;
}
static int int_to_roman ( int n , char * roman , size_t bufsize ) { char roman_symbol_labels [ 13 ] [ 3 ] = { " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " } ; int roman_symbol_values [ 13 ] = { 1000 , 900 , 500 , 400 , 100 , 90 , 50 , 40 , 10 , 9 , 5 , 4 , 1 } ; roman [ 0 ] = ' \0 ' ; if ( n < 1 ) return 0 ; while ( n > 0 ) { int i = 0 ; while ( n < roman_symbol_values [ i ] ) i ++ ; if ( strlen ( roman ) + strlen ( roman_symbol_labels [ i ] ) + 1 > bufsize ) break ; my_strcat ( roman , roman_symbol_labels [ i ] , bufsize ) ; n -= roman_symbol_values [ i ] ; } if ( n > 0 ) { roman [ 0 ] = ' \0 ' ; return 0 ; } return 1 ; }
Converts an arabic numeral (int) to a roman numeral (char *).
Converts an arabic numeral ( int ) to a roman numeral ( char * ) .
/* Roman symbols */ /* Clear the roman numeral buffer */ /* Roman numerals have no zero or negative numbers */ /* Build the roman numeral in the buffer */ /* Find the largest possible roman symbol */ /* No room in buffer, so abort */ /* Add the roman symbol to the buffer */ /* Decrease the value of the arabic numeral */ /* Ran out of space and aborted */ /* Clean up and return */