/* lread.c */
#include "longint.h"
/* setting LINT by string */
LINT lread(char *s)
{
LINT a;
int c[MAXLEN2], *pc;
char *ps;
int i, j, k, n;
i = 0;
while(++i <= MAXLEN) a.num[i] = 0;
if(strlen(s) < 5)
{
i = atoi(s);
a.sign = (i >= 0)? 0: -1;
if(i == 0) a.len = 0;
else
{
a.len = 1;
a.num[1] = (a.sign == 0)? i: -i;
}
return a;
}
ps = s;
n = 0;
pc = c;
a.sign = 0;
while(*ps && n < MAXLEN2)
{
*pc++ = *ps++ - '0';
n++;
}
j = 0;
a.len = i = --n / 4 + 1;
if(n % 4 != 3)
{
a.num[i] = 0;
do
{
a.num[i] *= 10;
a.num[i] += c[j++];
} while(--n % 4 != 3);
i--;
}
while(i >= 0)
{
a.num[i] = c[j++];
for(k = 0; k < 3; k++)
{
a.num[i] *= 10;
a.num[i] += c[j++];
}
i--;
}
return a;
}
|