Message-Id: <4.1.19991117155637.00a4b240@mail.student.unimelb.edu.au> X-Sender: surahyo AT mail DOT student DOT unimelb DOT edu DOT au X-Mailer: QUALCOMM Windows Eudora Pro Version 4.1 Date: Wed, 17 Nov 1999 16:21:16 +1100 To: djgpp AT delorie DOT com From: Surahyo Subject: math.h or math co-processor? In-Reply-To: <19991117022349.18670.rocketmail@web1403.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Reply-To: djgpp AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk Dear all, My system is 386SX-40, no math co-processor, 4 MB SIMM RAM, and 16 MB Flash Disk (the controller for vehicle navigation system). I used GCC ver 2.6.3 (gcc263bn.zip) since the latest one doesn't work on my system. I've put "set GO32=emu c:\bin\emu387" in my autoexec.bat for 387 emulation. I compiled the next source code on my system using the next command: gcc model.c -o model -lm and no errors. However, I got a wrong result when I run it. For example: Inputs: Current latitude & longitude: 1 1 Angle between centerline of vehicle and X axis: 0 Next latitude & longitude: 1 5 Outputs: Distance: 4 (OK) Angle between centerline of vehicle and X axis (before): 0 (OK) Steering angle: 87.616783 (wrong result, it should be 90) Angle between centerline of vehicle and X axis (after): 87.61676 (wrong result, it should be 90) What could be wrong? Anyway, I am still hoping to use the latest GCC on my system. However, every time I run it, my system reboot automatically. I've followed the advice in section 3.9 of the FAQ for the memory-starved systems. ---------------------------------------------------------------------------- ----------------------------------------------- /* Vehicle modeling */ #include #include main() { float x_curn, y_curn; float x_next, y_next; float alpha, distance; float beta, beta_next; printf( "Current latitude & longitude\n" ); scanf( "%f %f", &x_curn, &y_curn); printf( "Angle between centerline of vehicle and X axis\n" ); scanf( "%f", &beta); printf( "Next latitude & longitude\n" ); scanf( "%f %f", &x_next, &y_next ); distance = sqrt ( (x_next-x_curn)*(x_next-x_curn) + (y_next-y_curn)*(y_next-y_curn) ); alpha = 180/PI * acos ( (x_next-x_curn) / distance ) - beta; beta_next = beta + alpha; printf( "\nDistance between (%8.6f,%8.6f) and (%8.6f,%8.6f): %8.6f \nAngle between centerline of vehicle and X axis (before): %8.6f \nSteering angle: %8.6f \nAngle between centerline of vehicle and X axis (after): %8.6f", x_curn, y_curn, x_next, y_next, distance, beta, alpha, beta_next ); return 0; } ---------------------------------------------------------------------------- ----------------------------------------------