00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <pc_file.h>
00022
00023 #define BIG 1e17
00024
00025 extern _rf();
00026 extern _incpt();
00027 extern _skipsp();
00028 extern int _getsig();
00029 extern int _getint();
00030 extern int _fstdig();
00031 extern int _nxtdig();
00032
00033 static double r;
00034 static int pow10;
00035
00036 static dig(ch) int ch; {
00037
00038 if (r>BIG)
00039 pow10++;
00040 else
00041 r = r*10.0 + ch;
00042 }
00043
00044 double _rdr(f) struct file *f; {
00045 int i; double e; int is_signed,ch;
00046
00047 r = 0;
00048 pow10 = 0;
00049 _rf(f);
00050 _skipsp(f);
00051 is_signed = _getsig(f);
00052 ch = _fstdig(f);
00053 do
00054 dig(ch);
00055 while ((ch = _nxtdig(f)) >= 0);
00056 if (*f->ptr == '.') {
00057 _incpt(f);
00058 ch = _fstdig(f);
00059 do {
00060 dig(ch);
00061 pow10--;
00062 } while ((ch = _nxtdig(f)) >= 0);
00063 }
00064 if ((*f->ptr == 'e') || (*f->ptr == 'E')) {
00065 _incpt(f);
00066 pow10 += _getint(f);
00067 }
00068 if ((i = pow10) < 0)
00069 i = -i;
00070 e = 1.0;
00071 while (--i >= 0)
00072 e *= 10.0;
00073 if (pow10<0)
00074 r /= e;
00075 else
00076 r *= e;
00077 return(is_signed? -r : r);
00078 }