source: trunk/minix/lib/ack/libp/wrr.c@ 15

Last change on this file since 15 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 1.3 KB
Line 
1/* $Header: /cvsup/minix/src/lib/ack/libp/wrr.c,v 1.1 2005/10/10 15:27:47 beng Exp $ */
2/*
3 * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
4 *
5 * This product is part of the Amsterdam Compiler Kit.
6 *
7 * Permission to use, sell, duplicate or disclose this software must be
8 * obtained in writing. Requests for such permissions may be sent to
9 *
10 * Dr. Andrew S. Tanenbaum
11 * Wiskundig Seminarium
12 * Vrije Universiteit
13 * Postbox 7161
14 * 1007 MC Amsterdam
15 * The Netherlands
16 *
17 */
18
19/* Author: J.W. Stevenson */
20
21#include <pc_err.h>
22#include <pc_file.h>
23
24extern _wstrin();
25extern char *_ecvt();
26
27#define PREC_DIG 80 /* maximum digits produced by _ecvt() */
28
29_wsr(w,r,f) int w; double r; struct file *f; {
30 char *p,*b; int s,d,i; char buf[PREC_DIG+7];
31
32 if (w < 0) _trp(EWIDTH);
33 p = buf;
34 if ((i = w-6) < 2)
35 i = 2;
36 b = _ecvt(r,i,&d,&s);
37 *p++ = s? '-' : ' ';
38 if (*b == '0')
39 d++;
40 *p++ = *b++;
41 *p++ = '.';
42 while (--i > 0)
43 *p++ = *b++;
44 *p++ = 'e';
45 d--;
46 if (d < 0) {
47 d = -d;
48 *p++ = '-';
49 } else
50 *p++ = '+';
51
52 if (d >= 1000) {
53 *p++ = '*';
54 *p++ = '*';
55 *p++ = '*';
56 }
57 else {
58 *p++ = '0' + d/100;
59 *p++ = '0' + (d/10) % 10;
60 *p++ = '0' + d%10;
61 }
62 _wstrin(w,(int)(p-buf),buf,f);
63}
64
65_wrr(r,f) double r; struct file *f; {
66 _wsr(13,r,f);
67}
Note: See TracBrowser for help on using the repository browser.