Parse integer numbers from back to front.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai.u-szeged@partner.samsung.com
This commit is contained in:
Dániel Bátyai 2015-08-13 11:21:24 +02:00
parent 034ecf78f8
commit 91f0c9d625
2 changed files with 5 additions and 2 deletions

View File

@ -980,9 +980,10 @@ lexer_parse_number (void)
const lit_utf8_byte_t *fp_buf_p = TOK_START ();
/* token is constructed at end of function */
for (i = 0; i < tok_length; i++)
ecma_number_t mult = 1.0f;
for (i = tok_length; i > 0; i--, mult *= 10)
{
fp_res = fp_res * 10 + (ecma_number_t) lit_char_hex_to_int (fp_buf_p[i]);
fp_res += (ecma_number_t) lit_char_hex_to_int (fp_buf_p[i - 1]) * mult;
}
}
}

View File

@ -22,3 +22,5 @@ assert(big == 2147483648); // overflow on 32bit numbers
big++;
assert(big == 2147483649); // overflow on 32bit numbers
assert ((1152921504606846900).toString() === "1152921504606847000")