Multiply in C UDR
Posted in 2000
Topics: Data Types & Schema Design
I am trying to multiply an mi_decimal by an mi_double_precision and put the result into an mi_decimal in a C UDR. I cannot find any code examples working with these data types. Can anyone help me out with the code below, and can you point me to a source for more examples than the idn and programmers manual. Thanks: mi_decimal *unearned ( mi_date d_report, mi_date d_pol_eff, mi_date d_pol_exp, mi_integer days_in_term, mi_decimal * a_cvg_op, MI_FPARAM * Gen_fparam ) { mi_decimal * Gen_RetVal; MI_CONNECTION * Gen_Con; mi_double_precision * factor; /* Use the NULL connection. */ Gen_Con = NULL; Gen_RetVal = (mi_decimal *)mi_alloc( sizeof( mi_decimal ) ); factor = gf1(d_report, d_pol_eff, d_pol_exp, days_in_term); /* this is the problem section. I have tried the following: */ /* Yes I realize the decmul only multiplies decimals, but I */ /* I can't find a way to convert. */ /* decmul(a_cvg_op, factor, Gen_RetVal); */ /* Gen_RetVal = a_cvg_op * factor; */ /* Return the function's return value. */ return Gen_RetVal; } Sent via Deja.com http://www.deja.com/ Before you buy.
Use 'deccvdbl' to convert mi_double into mi_decimal before usage of 'decmul'. if ( !deccvdbl(*factor, Gen_RetVal ) ) decmul(a_cvg_op, Gen_RetVal, Gen_RetVal); else error ... Good luck. Sergey. <dgmyrs@my-deja.com> ''''' ' ''''''''':8tppmj$cor$1@nnrp1.deja.com... > I am trying to multiply an mi_decimal by an mi_double_precision and put > the result into an mi_decimal in a C UDR. I cannot find any code > examples working with these data types. Can anyone help me out with > the code below, and can you point me to a source for more examples than > the idn and programmers manual. Thanks: > > mi_decimal *unearned > ( > mi_date d_report, > mi_date d_pol_eff, > mi_date d_pol_exp, > mi_integer days_in_term, > mi_decimal * a_cvg_op, > MI_FPARAM * Gen_fparam > ) > { > mi_decimal * Gen_RetVal; > MI_CONNECTION * Gen_Con; > mi_double_precision * factor; > > /* Use the NULL connection. */ > Gen_Con = NULL; > > Gen_RetVal = (mi_decimal *)mi_alloc( sizeof( mi_decimal ) ); > > factor = gf1(d_report, d_pol_eff, d_pol_exp, days_in_term); > > /* this is the problem section. I have tried the following: */ > /* Yes I realize the decmul only multiplies decimals, but I */ > /* I can't find a way to convert. */ > /* decmul(a_cvg_op, factor, Gen_RetVal); */ > /* Gen_RetVal = a_cvg_op * factor; */ > > > /* Return the function's return value. */ > return Gen_RetVal; > } > > > Sent via Deja.com http://www.deja.com/ > Before you buy.