Hello bigmac and rocco, thanks for your reply.
This is the complete code, in my last post i have put less code for simplify the question, but in this way the information it is not full, sorry.
this is my code :
volt_T1=ADR; // get ADR value
freq_khz =AUX_K/HRPPER; // freq_khz between [40,120]
A_f = (((3 * freq_khz * freq_khz)/50)+(6 * freq_khz+8432));
//(3 * freq_khz * freq_khz) do not causes overflow in A_f?
B_f = (((9 * freq_khz * freq_khz)/10)+(2*freq_khz+12787))/10;
// 9 * freq_khz*freq_khz causes overflow and a bad B_f value?
// what is the solution? unsigned long?
volt_pk_T1_bin = (A_f * volt_T1 + B_f)/100;
// A_f * volt_T1 also causes overflow
Declaration of variables:
tU16 volt_pk_T1_bin; typedef unsigned int tU16;
extern tU16 extern tU16 A_f;;
tU16 A_f; typedef unsigned int tU16; extern tU16 A_f;
tU16 B_f; typedef unsigned int tU16; extern tU16 B_f;
//A_f, B_f, volt_pk_T1_bin are unsigned int global
Message Edited by rceit on 2006-06-11 05:44 AM