mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:17:35 +00:00
LibJS: Make string_to_double use the new double parser
This commit is contained in:
parent
6805ded21d
commit
783b1a479d
1 changed files with 4 additions and 4 deletions
|
@ -9,6 +9,7 @@
|
|||
#include <AK/AllOf.h>
|
||||
#include <AK/Assertions.h>
|
||||
#include <AK/CharacterTypes.h>
|
||||
#include <AK/FloatingPointStringConversions.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <AK/Utf8View.h>
|
||||
|
@ -549,12 +550,11 @@ Optional<Value> string_to_number(StringView string)
|
|||
return Value(bigint.to_double());
|
||||
}
|
||||
|
||||
char* endptr;
|
||||
auto parsed_double = strtod(text.characters(), &endptr);
|
||||
if (*endptr)
|
||||
auto maybe_double = text.to_double(AK::TrimWhitespace::No);
|
||||
if (!maybe_double.has_value())
|
||||
return js_nan();
|
||||
|
||||
return Value(parsed_double);
|
||||
return Value(*maybe_double);
|
||||
}
|
||||
|
||||
// 7.1.4 ToNumber ( argument ), https://tc39.es/ecma262/#sec-tonumber
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue