diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-global.cpp b/jerry-core/ecma/builtin-objects/ecma-builtin-global.cpp index 9af6eeffb..a29ec54f4 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-global.cpp +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-global.cpp @@ -531,31 +531,35 @@ ecma_builtin_global_object_parse_float (ecma_value_t this_arg __attr_unused___, if (str_curr_p < str_end_p) { current = *str_curr_p; - } - /* Check decimal point. */ - if (current == LIT_CHAR_DOT && str_curr_p < str_end_p) - { - current = *(++str_curr_p); - - if (lit_char_is_decimal_digit (current)) + /* Check decimal point. */ + if (current == LIT_CHAR_DOT) { - has_fraction_part = true; str_curr_p++; - /* Check digits of fractional part. */ - while (str_curr_p < str_end_p) + if (str_curr_p < str_end_p) { - current = *str_curr_p++; - if (!lit_char_is_decimal_digit (current)) + current = *str_curr_p; + + if (lit_char_is_decimal_digit (current)) { - str_curr_p--; - break; + has_fraction_part = true; + + /* Check digits of fractional part. */ + while (str_curr_p < str_end_p) + { + current = *str_curr_p++; + if (!lit_char_is_decimal_digit (current)) + { + str_curr_p--; + break; + } + } + + /* Set end position to end of fraction part. */ + end_p = str_curr_p; } } - - /* Set end position to end of fraction part. */ - end_p = str_curr_p; } } diff --git a/tests/jerry/global-parsefloat.js b/tests/jerry/global-parsefloat.js index 6765b5543..3fa87e813 100644 --- a/tests/jerry/global-parsefloat.js +++ b/tests/jerry/global-parsefloat.js @@ -23,6 +23,8 @@ assert(parseFloat("1.2e3") === 1200); assert(parseFloat("+1.2e3") === 1200); assert(parseFloat("-1.2e3") === -1200); assert(parseFloat(" \n\t 1.2e3") === 1200); +assert(parseFloat("03.02e1") === 30.2); +assert(parseFloat("003.") === 3); assert(parseFloat(".2e3") === 200); assert(parseFloat("1.e3") === 1000); assert(parseFloat("1.2e") === 1.2);