mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
AK: Add String to number floating point support
This commit is contained in:
parent
2361ce25a0
commit
4a7d3115c9
Notes:
sideshowbarker
2024-07-17 03:03:15 +09:00
Author: https://github.com/bplaat Commit: https://github.com/SerenityOS/serenity/commit/4a7d3115c9 Pull-request: https://github.com/SerenityOS/serenity/pull/21622 Reviewed-by: https://github.com/AtkinsSJ ✅
1 changed files with 4 additions and 0 deletions
|
@ -181,6 +181,10 @@ public:
|
|||
template<Arithmetic T>
|
||||
Optional<T> to_number(TrimWhitespace trim_whitespace = TrimWhitespace::Yes) const
|
||||
{
|
||||
#ifndef KERNEL
|
||||
if constexpr (IsFloatingPoint<T>)
|
||||
return StringUtils::convert_to_floating_point<T>(bytes_as_string_view(), trim_whitespace);
|
||||
#endif
|
||||
if constexpr (IsSigned<T>)
|
||||
return StringUtils::convert_to_int<T>(bytes_as_string_view(), trim_whitespace);
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue