base/math/m_decimal.c
/*! Duplicate dec1 and dec2 into tdec1 and tdec2, respectively.  Reduce to lowest
 *  possible number of decimal places for each, then convert both to have the
 *  same number of decimal places ... may require truncation of decimal places
 *  if both can't be represented in the max */
Duplicate dec1 and dec2 into tdec1 and tdec2, respectively.  Reduce to lowest
possible number of decimal places for each, then convert both to have the
same number of decimal places ... may require truncation of decimal places
if both can't be represented in the max
Duplicate dec1 and dec2 into tdec1 and tdec2 respectively . Reduce to lowest possible number of decimal places for each then convert both to have the same number of decimal places ... may require truncation of decimal places if both can ' t be represented in the max
static enum M_DECIMAL_RETVAL M_decimal_prepmath(M_decimal_t *tdec1, M_decimal_t *tdec2, const M_decimal_t *dec1, const M_decimal_t *dec2, M_bool reduce_dec)
{
	M_uint8 wanted_dec;
	M_uint8 num_dec;
	if (tdec1 == NULL || tdec2 == NULL || dec1 == NULL || dec2 == NULL)
		return M_DECIMAL_INVALID;
	M_decimal_duplicate(tdec1, dec1);
	M_decimal_duplicate(tdec2, dec2);
	if (reduce_dec) {
		M_decimal_reduce(tdec1);
		M_decimal_reduce(tdec2);
	}
	wanted_dec = M_MAX(tdec1->num_dec, tdec2->num_dec);
	num_dec    = wanted_dec;
	do {
		if (M_decimal_transform(tdec1, num_dec, M_DECIMAL_ROUND_TRADITIONAL) != M_DECIMAL_OVERFLOW &&
		    M_decimal_transform(tdec2, num_dec, M_DECIMAL_ROUND_TRADITIONAL) != M_DECIMAL_OVERFLOW)
			break;
		if (num_dec == 0)
			return M_DECIMAL_INVALID;
		num_dec--;
		M_decimal_duplicate(tdec1, dec1);
		M_decimal_duplicate(tdec2, dec2);
	} while(1);
	if (num_dec != wanted_dec)
		return M_DECIMAL_TRUNCATION;
	return M_DECIMAL_SUCCESS;
}
static enum M_DECIMAL_RETVAL M_decimal_prepmath ( M_decimal_t * tdec1 , M_decimal_t * tdec2 , const M_decimal_t * dec1 , const M_decimal_t * dec2 , M_bool reduce_dec ) { M_uint8 wanted_dec ; M_uint8 num_dec ; if ( tdec1 == NULL || tdec2 == NULL || dec1 == NULL || dec2 == NULL ) return M_DECIMAL_INVALID ; M_decimal_duplicate ( tdec1 , dec1 ) ; M_decimal_duplicate ( tdec2 , dec2 ) ; if ( reduce_dec ) { M_decimal_reduce ( tdec1 ) ; M_decimal_reduce ( tdec2 ) ; } wanted_dec = M_MAX ( tdec1 -> num_dec , tdec2 -> num_dec ) ; num_dec = wanted_dec ; do { if ( M_decimal_transform ( tdec1 , num_dec , M_DECIMAL_ROUND_TRADITIONAL ) != M_DECIMAL_OVERFLOW && M_decimal_transform ( tdec2 , num_dec , M_DECIMAL_ROUND_TRADITIONAL ) != M_DECIMAL_OVERFLOW ) break ; if ( num_dec == 0 ) return M_DECIMAL_INVALID ; num_dec -- ; M_decimal_duplicate ( tdec1 , dec1 ) ; M_decimal_duplicate ( tdec2 , dec2 ) ; } while ( 1 ) ; if ( num_dec != wanted_dec ) return M_DECIMAL_TRUNCATION ; return M_DECIMAL_SUCCESS ; }
Duplicate dec1 and dec2 into tdec1 and tdec2, respectively.
Duplicate dec1 and dec2 into tdec1 and tdec2 respectively .
/* Shouldn't be possible */