struct tmp_state {
char state[3];
int dh_miles;
int b_miles;
int n_loads;
float lhrev;
float lhtotal;
} temp_state[MAXSTATE];
struct tmp_print {
char state[3];
int dh_miles;
float percent_dh;
int n_loads;
int average_dh;
int b_miles;
int average_loh;
float lhrev;
float lhrev_wo_dh;
float lhrev_w_dh;
float lhrev_acc;
float lhrev_acc_wo_dh;
float lhrev_acc_w_dh;
} temp_print[MAXPRINT];
I am trying to do this:
temp_print.percent_dh = (temp_state.lhrev/(temp_state.b_miles+temp_state.dh_miles)*100);
I am not sure what the problem is, not matter how I try this, temp_print.percent_dh is ALWAYS 0.00. I have tried to put b_miles+dh_miles into a total_miles and then divide it by dh_miles, and I still get the same thing, 0.00.
Is there a problem with b_miles and dh_miles being intager type and percent_dh being float????
I have even tried to make percent_dh a char and print the results into percent_dh with sprintf.
Any ideas as to what might be happening here?
char state[3];
int dh_miles;
int b_miles;
int n_loads;
float lhrev;
float lhtotal;
} temp_state[MAXSTATE];
struct tmp_print {
char state[3];
int dh_miles;
float percent_dh;
int n_loads;
int average_dh;
int b_miles;
int average_loh;
float lhrev;
float lhrev_wo_dh;
float lhrev_w_dh;
float lhrev_acc;
float lhrev_acc_wo_dh;
float lhrev_acc_w_dh;
} temp_print[MAXPRINT];
I am trying to do this:
temp_print.percent_dh = (temp_state.lhrev/(temp_state.b_miles+temp_state.dh_miles)*100);
I am not sure what the problem is, not matter how I try this, temp_print.percent_dh is ALWAYS 0.00. I have tried to put b_miles+dh_miles into a total_miles and then divide it by dh_miles, and I still get the same thing, 0.00.
Is there a problem with b_miles and dh_miles being intager type and percent_dh being float????
I have even tried to make percent_dh a char and print the results into percent_dh with sprintf.
Any ideas as to what might be happening here?