1994-06-24 14:02:31 +00:00
|
|
|
/* $Id$ */
|
1984-07-20 10:44:57 +00:00
|
|
|
/*
|
|
|
|
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
|
|
|
*
|
|
|
|
* This product is part of the Amsterdam Compiler Kit.
|
|
|
|
*
|
|
|
|
* Permission to use, sell, duplicate or disclose this software must be
|
|
|
|
* obtained in writing. Requests for such permissions may be sent to
|
|
|
|
*
|
|
|
|
* Dr. Andrew S. Tanenbaum
|
|
|
|
* Wiskundig Seminarium
|
|
|
|
* Vrije Universiteit
|
|
|
|
* Postbox 7161
|
|
|
|
* 1007 MC Amsterdam
|
|
|
|
* The Netherlands
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Author: J.W. Stevenson */
|
|
|
|
|
2018-06-17 14:11:29 +00:00
|
|
|
#include <pc_err.h>
|
|
|
|
#include <pc_file.h>
|
1984-07-20 10:44:57 +00:00
|
|
|
|
2018-06-17 14:11:29 +00:00
|
|
|
extern _wstrin();
|
|
|
|
extern char* _ecvt();
|
1984-07-20 10:44:57 +00:00
|
|
|
|
2018-06-17 14:11:29 +00:00
|
|
|
#define PREC_DIG 80 /* maximum digits produced by _ecvt() */
|
1984-07-20 10:44:57 +00:00
|
|
|
|
2018-06-17 14:11:29 +00:00
|
|
|
_wsr(w, r, f) int w;
|
|
|
|
double r;
|
|
|
|
struct file* f;
|
|
|
|
{
|
|
|
|
char *p, *b;
|
|
|
|
int s, d, i;
|
|
|
|
char buf[PREC_DIG + 7];
|
1984-07-20 10:44:57 +00:00
|
|
|
|
2018-06-17 14:11:29 +00:00
|
|
|
if (w < 0)
|
|
|
|
_trp(EWIDTH);
|
1984-07-20 10:44:57 +00:00
|
|
|
p = buf;
|
2018-06-17 14:11:29 +00:00
|
|
|
if ((i = w - 6) < 2)
|
1984-07-20 10:44:57 +00:00
|
|
|
i = 2;
|
2018-06-17 14:11:29 +00:00
|
|
|
b = _ecvt(r, i, &d, &s);
|
|
|
|
*p++ = s ? '-' : ' ';
|
1984-07-20 10:44:57 +00:00
|
|
|
if (*b == '0')
|
|
|
|
d++;
|
|
|
|
*p++ = *b++;
|
|
|
|
*p++ = '.';
|
|
|
|
while (--i > 0)
|
|
|
|
*p++ = *b++;
|
|
|
|
*p++ = 'e';
|
|
|
|
d--;
|
2018-06-17 14:11:29 +00:00
|
|
|
if (d < 0)
|
|
|
|
{
|
1984-07-20 10:44:57 +00:00
|
|
|
d = -d;
|
|
|
|
*p++ = '-';
|
2018-06-17 14:11:29 +00:00
|
|
|
}
|
|
|
|
else
|
1984-07-20 10:44:57 +00:00
|
|
|
*p++ = '+';
|
1989-05-03 09:53:25 +00:00
|
|
|
|
2018-06-17 14:11:29 +00:00
|
|
|
if (d >= 1000)
|
|
|
|
{
|
1989-05-03 09:53:25 +00:00
|
|
|
*p++ = '*';
|
|
|
|
*p++ = '*';
|
|
|
|
*p++ = '*';
|
|
|
|
}
|
2018-06-17 14:11:29 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
*p++ = '0' + d / 100;
|
|
|
|
*p++ = '0' + (d / 10) % 10;
|
|
|
|
*p++ = '0' + d % 10;
|
1989-05-03 09:53:25 +00:00
|
|
|
}
|
2018-06-17 14:11:29 +00:00
|
|
|
_wstrin(w, (int)(p - buf), buf, f);
|
1984-07-20 10:44:57 +00:00
|
|
|
}
|
|
|
|
|
2018-06-17 14:11:29 +00:00
|
|
|
_wrr(r, f) double r;
|
|
|
|
struct file* f;
|
|
|
|
{
|
|
|
|
_wsr(13, r, f);
|
1984-07-20 10:44:57 +00:00
|
|
|
}
|