source: trunk/minix/lib/ack/libp/rdr.c@ 10

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

Minix 3.1.2a

File size: 1.4 KB
Line 
1/* $Header: /cvsup/minix/src/lib/ack/libp/rdr.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_file.h>
22
23#define BIG 1e17
24
25extern _rf();
26extern _incpt();
27extern _skipsp();
28extern int _getsig();
29extern int _getint();
30extern int _fstdig();
31extern int _nxtdig();
32
33static double r;
34static int pow10;
35
36static dig(ch) int ch; {
37
38 if (r>BIG)
39 pow10++;
40 else
41 r = r*10.0 + ch;
42}
43
44double _rdr(f) struct file *f; {
45 int i; double e; int is_signed,ch;
46
47 r = 0;
48 pow10 = 0;
49 _rf(f);
50 _skipsp(f);
51 is_signed = _getsig(f);
52 ch = _fstdig(f);
53 do
54 dig(ch);
55 while ((ch = _nxtdig(f)) >= 0);
56 if (*f->ptr == '.') {
57 _incpt(f);
58 ch = _fstdig(f);
59 do {
60 dig(ch);
61 pow10--;
62 } while ((ch = _nxtdig(f)) >= 0);
63 }
64 if ((*f->ptr == 'e') || (*f->ptr == 'E')) {
65 _incpt(f);
66 pow10 += _getint(f);
67 }
68 if ((i = pow10) < 0)
69 i = -i;
70 e = 1.0;
71 while (--i >= 0)
72 e *= 10.0;
73 if (pow10<0)
74 r /= e;
75 else
76 r *= e;
77 return(is_signed? -r : r);
78}
Note: See TracBrowser for help on using the repository browser.