Mail Archives: djgpp/2005/03/04/14:37:55
I have a problem I'm having a really tough time tracking down. Below is the
code. out_xxxx.c calls function cyl_volume() which is in bm_xxxx.c. As I go
along, I'm checking all the results against a Texas Instruments TI-30Xa
calculator.
THIS IS IN OUT_XXXX.C
/*
locate(5,5);
printf("Computing CYLINDER VOLUME ... ");
*/
temp = 0.0;
temp = cyl_volume(&eng_0);
locate(5,5);
printf("ptr_sim_0->V_1_ci = %10.6f, temp = %10.6f",
ptr_sim_0->V_1_ci, temp);
locate(13,5);
ptr_sim_0->V_1_ci = cyl_volume(&eng_0); /* this is in bm_xxxx.c
*/
locate(13,5);
printf("CYLINDER VOLUME - %10.6f cubic inches", ptr_sim_0->V_1_ci);
pause(0);
THIS IS IN BM_XXXX.C
float cyl_volume(ENGINE *ptr_eng_0)
{
float cyl_vol = 0.0;
float temp1 = 0.0, temp2 = 0.0, temp3 = 0.0;
cyl_vol = PI * (pow(ptr_eng_0->bore/2, 2)) *
ptr_eng_0->stroke;
/* start debug */
locate(7,5);
printf("inside cyl_volume()");
locate(8,5);
printf("ptr_eng_0->bore = %10.6f, ptr_eng_0->stroke = %10.6f",
ptr_eng_0->bore, ptr_eng_0->stroke);
locate(9,5);
printf("ptr_eng_0->bore/2 = %10.6f, pow(ptr_eng_0->bore/2, 2) = %10.6f",
ptr_eng_0->bore/2, pow(ptr_eng_0->bore/2, 2));
locate(10,5);
printf("PI = %10.10f, cyl_vol = %10.6f", PI, cyl_vol);
locate(11,5);
temp1 = pow(ptr_eng_0->bore/2, 2);
temp2 = temp1 * ptr_eng_0->stroke;
temp3 = temp2 * PI;
printf("temp1 = %10.6f, temp2 = %10.6f, temp3 = %10.6f", temp1, temp2,
temp3);
return temp3;
/* end debug */
/* return cyl_vol; */
}
THIS IS RESULTS ON SCREEN
ptr_sim_0->V_1_ci = 0.000000, temp = 1102290688.000000
inside cyl_volume())
ptr_eng_0->bore = 2.975000, ptr_eng_0->stroke = 3.230000
ptr_eng_0->bore/2 = 1.487500, pow(ptr_eng_0->bore/2, 2) = 2.212656
PI = 3.1415927000, cyl_vol = 22.452583
temp1 = 2.212656, temp2 = 7.146879, temp3 = 22.452583
CYLINDER VOLUME - 1102290688.000000 cubic inches
As you can see from the section titles "THIS IS RESULTS ON SCREEN" even though
temp3 contains the correct value, it doesn't seem to be returned as such. All
assigned values and computed values check out OK within the cyl_volume()
function. Again, this is shown by the "RESULTS" screen.
Any help would be appreciated.
Bill
********************************************************************
Keller Racing
Performance by Design
KellerRcng AT cs DOT com
http://www.bylleet.com/kz_racing
http://ourworld.compuserve.com/homepages/nostalgia_drag_bike
SUPPORT YOUR LOCAL DRAG RACER!!
********************************************************************
- Raw text -