atolfp.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* Copyright (c) 1996 by Sun Microsystems, Inc.
* All Rights Reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* atolfp - convert an ascii string to an l_fp number
*/
#include <stdio.h>
#include <ctype.h>
#include "ntp_fp.h"
#include "ntp_string.h"
/*
* Powers of 10
*/
0,
10,
100,
1000,
10000,
100000,
1000000,
10000000,
100000000,
1000000000,
};
int
const char *str;
{
register const char *cp;
char *ind;
int ndec;
int isneg;
static const char *digits = "0123456789";
isneg = 0;
ndec = 0;
/*
* We understand numbers of the form:
*
* [spaces][-|+][digits][.][digits][spaces|\n|\0]
*/
cp++;
if (*cp == '-') {
cp++;
isneg = 1;
}
if (*cp == '+')
cp++;
return 0;
cp++;
}
if (*cp++ != '.')
return 0;
ndec++;
cp++;
}
cp++;
return 0;
}
if (ndec > 0) {
tmp = 0;
bit = 0x80000000;
while (bit != 0) {
dec_f <<= 1;
}
bit >>= 1;
}
tmp++;
}
if (isneg)
return 1;
}