[bugfix] too long fraction causes overflow
This commit is contained in:
parent
4cd8dcab60
commit
1fe960716e
|
@ -267,21 +267,21 @@ read_suffix(pic_state *pic, struct pic_port *port)
|
||||||
static pic_value
|
static pic_value
|
||||||
read_unsigned(pic_state *pic, struct pic_port *port, int c)
|
read_unsigned(pic_state *pic, struct pic_port *port, int c)
|
||||||
{
|
{
|
||||||
unsigned u, w = 0;
|
unsigned u;
|
||||||
int exp, s, i, e;
|
int exp, s, i, e;
|
||||||
double f;
|
double f, g;
|
||||||
|
|
||||||
u = read_uinteger(pic, port, c);
|
u = read_uinteger(pic, port, c);
|
||||||
|
|
||||||
switch (peek(port)) {
|
switch (peek(port)) {
|
||||||
case '.':
|
case '.':
|
||||||
next(port);
|
next(port);
|
||||||
w = 0, f = 1;
|
g = 0, e = 0;
|
||||||
while (isdigit(c = peek(port))) {
|
while (isdigit(c = peek(port))) {
|
||||||
w = w * 10 + next(port) - '0';
|
g = g * 10 + (next(port) - '0');
|
||||||
f /= 10;
|
e++;
|
||||||
}
|
}
|
||||||
f = u + w * f;
|
f = u + g * pow(10, -e);
|
||||||
|
|
||||||
exp = read_suffix(pic, port);
|
exp = read_suffix(pic, port);
|
||||||
if (exp >= 0) {
|
if (exp >= 0) {
|
||||||
|
|
Loading…
Reference in New Issue