BugFix:Number.parseFloat("10000000000000000000000.0") Get an error result

modify NumberHelper::StringToDouble , set exponent 0 in  step 8. parse '.'
issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I8D716
Signed-off-by: hecunmao <hecunmao@huawei.com>

Change-Id: Ic5f1a2cfdc9ee04a12b328f72e153be949a639ee
This commit is contained in:
hecunmao 2023-11-02 20:17:04 +08:00
parent d29a1082fb
commit 3fa37c9f1e
3 changed files with 5 additions and 0 deletions

View File

@ -609,6 +609,7 @@ double NumberHelper::StringToDouble(const uint8_t *start, const uint8_t *end, ui
}
// 8. parse '.'
exponent = 0;
if (radix == DECIMAL && *p == '.') {
RETURN_IF_CONVERSION_END(++p, end, (digits > 0 || (digits == 0 && leadingZero)) ?
(number * std::pow(radix, exponent)) : NAN_VALUE);

View File

@ -109,4 +109,7 @@ print(s)
print(Number.parseInt("4294967294"))
print(Number.parseInt("2147483648"))
print(Number.parseFloat("10000000000000000000000.0"));
print("builtins number end");

View File

@ -99,6 +99,7 @@ TypeError: Cannot convert a BigInt value to a number
0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000034lmua2oev
4294967294
2147483648
1e+22
builtins number end
builtins regexp start
20210608_5V0J5lVh4xVNYx0AUE.jpg,.jpg