From cba388b1dcdbb9696fcf07b5246ebad09979aea7 Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Mon, 26 Aug 2024 10:47:39 -0400 Subject: [PATCH] Update README.md --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 0d0f0d3..b4df3ba 100644 --- a/README.md +++ b/README.md @@ -180,6 +180,15 @@ Hence, we have the following examples: // result == std::numeric_limits::infinity() ``` +Users who wish for the value to be left unmodified given `std::errc::result_out_of_range` may do so by adding two lines of code: + +```cpp + double old_result = result; // make copy + auto r = fast_float::from_chars(start, end, result); + if(r.ec == std::errc::result_out_of_range) { result = old_result; } +``` + + ## C++20: compile-time evaluation (constexpr) In C++20, you may use `fast_float::from_chars` to parse strings