Skip to content

Commit c6303d3

Browse files
committed
Merge branch 'main' of github.com:fastfloat/fast_float
2 parents fde0116 + d41d507 commit c6303d3

File tree

4 files changed

+62
-48
lines changed

4 files changed

+62
-48
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ The library seeks to follow the C++17 (see [20.19.3](http://eel.is/c++draft/char
6666
Furthermore, we have the following restrictions:
6767
* We only support `float` and `double` types at this time.
6868
* We only support the decimal format: we do not support hexadecimal strings.
69-
* For values that are either very large or very small (e.g., `1e9999`), we represent it using the infinity or negative infinity value.
69+
* For values that are either very large or very small (e.g., `1e9999`), we represent it using the infinity or negative infinity value and the returned `ec` is set to `std::errc::result_out_of_range`.
7070

7171
We support Visual Studio, macOS, Linux, freeBSD. We support big and little endian. We support 32-bit and 64-bit systems.
7272

include/fast_float/parse_number.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,10 @@ from_chars_result from_chars_advanced(const char *first, const char *last,
214214
// then we need to go the long way around again. This is very uncommon.
215215
if(am.power2 < 0) { am = digit_comp<T>(pns, am); }
216216
to_float(pns.negative, am, value);
217+
// Test for over/underflow.
218+
if ((pns.mantissa != 0 && am.mantissa == 0 && am.power2 == 0) || am.power2 == binary_format<T>::infinite_power()) {
219+
answer.ec = std::errc::result_out_of_range;
220+
}
217221
return answer;
218222
}
219223

0 commit comments

Comments
 (0)