Article View: net.lang.c
Article #9351Re: Help with BDSC float
From: bert
Date: Tue, 16 Sep 1986 15:08
Date: Tue, 16 Sep 1986 15:08
35 lines
1838 bytes
1838 bytes
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.
Technical Details
Message-ID:
<5000001@infoswx>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!seismo!lll-crg!lll-lcc!qantel!ihnp4!inuxc!pur-ee!uiucdcs!convex!infoswx!bertReferences:
<3211@mit-eddie.MIT.EDU>Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!lll-crg!lll-lcc!qantel!ihnp4!inuxc!pur-ee!uiucdcs!convex!infoswx!bert From: bert@infoswx.UUCP Newsgroups: net.lang.c Subject: Re: Help with BDSC float Message-ID: <5000001@infoswx> Date: Tue, 16-Sep-86 11:08:00 EDT Article-I.D.: infoswx.5000001 Posted: Tue Sep 16 11:08:00 1986 Date-Received: Sat, 20-Sep-86 20:57:45 EDT References: <3211@mit-eddie.MIT.EDU> Lines: 35 Nf-ID: #R:mit-eddie.MIT.EDU:3211:infoswx:5000001:000:1229 Nf-From: infoswx.UUCP!bert Sep 16 10:08:00 1986