You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+49-23Lines changed: 49 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,8 +21,8 @@ struct from_chars_result {
21
21
```
22
22
23
23
It parses the character sequence [first,last) for a number. It parses floating-point numbers expecting
24
-
a locale-independent format equivalent to the C++17 from_chars function.
25
-
The resulting floating-point value is the closest floating-point values (using either float or double),
24
+
a locale-independent format equivalent to the C++17 from_chars function.
25
+
The resulting floating-point value is the closest floating-point values (using either float or double),
26
26
using the "round to even" convention for values that would otherwise fall right in-between two values.
27
27
That is, we provide exact parsing according to the IEEE standard.
28
28
@@ -40,7 +40,7 @@ Example:
40
40
```C++
41
41
#include"fast_float/fast_float.h"
42
42
#include<iostream>
43
-
43
+
44
44
intmain() {
45
45
const std::string input = "3.1416 xyz ";
46
46
double result;
@@ -53,15 +53,15 @@ int main() {
53
53
54
54
55
55
Like the C++17 standard, the `fast_float::from_chars` functions take an optional last argument of
56
-
the type `fast_float::chars_format`. It is a bitset value: we check whether
56
+
the type `fast_float::chars_format`. It is a bitset value: we check whether
57
57
`fmt & fast_float::chars_format::fixed` and `fmt & fast_float::chars_format::scientific` are set
58
58
to determine whether we allow the fixed point and scientific notation respectively.
59
59
The default is `fast_float::chars_format::general` which allows both `fixed` and `scientific`.
60
60
61
-
The library seeks to follow the C++17 (see [20.19.3](http://eel.is/c++draft/charconv.from.chars).(7.1)) specification.
61
+
The library seeks to follow the C++17 (see [20.19.3](http://eel.is/c++draft/charconv.from.chars).(7.1)) specification.
62
62
* The `from_chars` function does not skip leading white-space characters.
63
63
*[A leading `+` sign](https://en.cppreference.com/w/cpp/utility/from_chars) is forbidden.
64
-
* It is generally impossible to represent a decimal value exactly as binary floating-point number (`float` and `double` types). We seek the nearest value. We round to an even mantissa when we are in-between two binary floating-point numbers.
64
+
* It is generally impossible to represent a decimal value exactly as binary floating-point number (`float` and `double` types). We seek the nearest value. We round to an even mantissa when we are in-between two binary floating-point numbers.
65
65
66
66
Furthermore, we have the following restrictions:
67
67
* We only support `float` and `double` types at this time.
@@ -76,16 +76,16 @@ We support Visual Studio, macOS, Linux, freeBSD. We support big and little endia
76
76
77
77
78
78
The C++ standard stipulate that `from_chars` has to be locale-independent. In
79
-
particular, the decimal separator has to be the period (`.`). However,
80
-
some users still want to use the `fast_float` library with in a locale-dependent
79
+
particular, the decimal separator has to be the period (`.`). However,
80
+
some users still want to use the `fast_float` library with in a locale-dependent
81
81
manner. Using a separate function called `from_chars_advanced`, we allow the users
82
-
to pass a `parse_options` instance which contains a custom decimal separator (e.g.,
82
+
to pass a `parse_options` instance which contains a custom decimal separator (e.g.,
The fast_float library is part of GCC (as of version 12): the `from_chars` function in GCC relies on fast_float.
116
142
117
-
The fastfloat algorithm is part of the [LLVM standard libraries](https://github.com/llvm/llvm-project/commit/87c016078ad72c46505461e4ff8bfa04819fe7ba).
143
+
The fastfloat algorithm is part of the [LLVM standard libraries](https://github.com/llvm/llvm-project/commit/87c016078ad72c46505461e4ff8bfa04819fe7ba).
118
144
119
145
The fast_float library provides a performance similar to that of the [fast_double_parser](https://github.com/lemire/fast_double_parser) library but using an updated algorithm reworked from the ground up, and while offering an API more in line with the expectations of C++ programmers. The fast_double_parser library is part of the [Microsoft LightGBM machine-learning framework](https://github.com/microsoft/LightGBM).
120
146
@@ -132,14 +158,14 @@ It can parse random floating-point numbers at a speed of 1 GB/s on some systems.
0 commit comments