Help with BDSC float
bert at infoswx.UUCP
bert at infoswx.UUCP
Wed Sep 17 01:08:00 AEST 1986
About float in BDSC. (I'm talking about the CPM version that I have used)
Basically, BDSC does not have float. There is a library of float
functions available that will allow you to do some floating point
operations with some difficulty. To use them, you must declare a 5 char
array for each float variable. You assign it a value with a function.
You play with it with other functions. Then you can print it with
a special printf routine that you must link in specifically to handle
the %e and %f control strings. But don't try to use fprintf if you
link the float printf stuff in, it doesn't work on the version I have.
examples:
char float1[5], float2[5];
buf[30];
atof(float1, "10.0"); /* set float to 10.0 */
fpadd(float1, float1, atof(float2, "5.0"); /* add 5 to it */
fpsub(float1, float1, atof(float2, "2.0"); /* subtract 2 from it */
fpmult(float1, float1, float2); /* multiply it by 5 */
fpdiv(float1, float1, float2); /* divide it by 5 */
ftoa(buf, float1); /* make ascii (%e format) */
printf("%f %s\n", float1, buf); /* print it (%f, %e) */
Note that the result is left in the first arg on all the arith operations.
Also, they all return char * to the result.
Bert Campbell.
More information about the Comp.lang.c
mailing list