The code being reposted reminded me to try again, which I did, and this
time it worked. Is your code public domain? BFN. Paul.
/* Written by Roy McNeill */
/* Copyright status unknown */
/* Modified by Paul Edwards */
/* Set i to the number you want the reciprocal of */
#define PLACES 501
#include
#include
#include
int main(void)
{
long i, j, top;
int place;
char ans[PLACES + 1], buf[40];
i = 300;
top = 1;
for (place = 0; place < PLACES; place++)
{
j = top / i; /* divide */
ltoa(j, buf, 10); /* convert to string. Answer should be 1
digit. */
ans[place] = *buf; /* add digit to big answer */
top = top - j * i; /* get remainder */
top *= 10; /* shift one decimal place */
}
ans[PLACES] = '\0';
printf("ans is %s\n", ans);
return 0;
}
@EOT:
---
* Origin: X (3:711/934.9)
|