CompuServe Messages

Math in processes

    29-Jan-95 17:47:49
Sb: Math in processes
Fm: Shraddhan 70374,754
To: All
Many thanks to everybody who has helped me in the last couple of months. I'm beginning to get the hang of C at last. Apologies for not replying to all who helped. Now can someone help me with the following program, please? The Process_Test routine is called twice, first as a process and then as a normal routine. When it runs as a process, it gives a different output. Why? It seems that the IEEEDPFix routine rounds to the nearest integer when running as a process, but truncates towards zero otherwise. The RKMs are not specific on which of these behaviours is the correct one. My Amiga 2000, WB3.1 has a math FPU fitted, if that makes any difference. #include <math.h> #include <libraries/mathieeedp.h> #include <dos/dostags.h> double val; BOOL done; void DoDigit() { int n; n = IEEEDPFix( val ); printf("Character '%c', n = %d\n", '0' + n, n); val = (val – IEEEDPFlt(n)) * 10.0; } __geta4 void Process_Test() { int i; val = 3.1415926535898; for (i = 0; i < 7; i++) DoDigit( val ); done = TRUE; } void main() { printf("\nRun process:\n"); CreateNewProcTags( NP_Entry, Process_Test, TAG_DONE ); done = FALSE; while (! done ) Delay(1); printf("\nCall directly:\n"); Process_Test(); } Regards, Shraddhan (via AP from Hertfordshire, England)