File tree Expand file tree Collapse file tree 2 files changed +16
-17
lines changed
Expand file tree Collapse file tree 2 files changed +16
-17
lines changed Original file line number Diff line number Diff line change 22#define __FAST_FLOAT_STRTOD_H__
33
44#if defined(__cplusplus )
5- extern "C"
6- {
5+ extern "C" {
76#endif
87/**
98 * @brief Convert a string to a double using the fast_float library. This is
10- * a C-compatible wrapper around the fast_float parsing functionality, designed to
11- * mimic the behavior of the standard strtod function.
9+ * a C-compatible wrapper around the fast_float parsing functionality, designed
10+ * to mimic the behavior of the standard strtod function.
1211 *
1312 * This function parses the initial portion of the null-terminated string `nptr`
1413 * and converts it to a `double`, similar to the standard `strtod` function but
@@ -23,7 +22,7 @@ extern "C"
2322 * to the beginning of the string.
2423 * @return The converted double value on success, or 0.0 on failure.
2524 */
26- double fast_float_strtod (const char * in , char * * out );
25+ double fast_float_strtod (const char * in , char * * out );
2726
2827#if defined(__cplusplus )
2928 }
Original file line number Diff line number Diff line change 55#include < system_error>
66
77extern " C" double fast_float_strtod (const char *nptr, char **endptr) {
8- double result = 0.0 ;
8+ double result = 0.0 ;
99
10- // Parse the string using fast_float's from_chars function
11- auto parse_result = fast_float::from_chars (nptr, nptr + strlen (nptr), result);
10+ // Parse the string using fast_float's from_chars function
11+ auto parse_result = fast_float::from_chars (nptr, nptr + strlen (nptr), result);
1212
13- // Check if parsing encountered an error
14- if (parse_result.ec != std::errc{}) {
15- errno = EINVAL;
16- }
13+ // Check if parsing encountered an error
14+ if (parse_result.ec != std::errc{}) {
15+ errno = EINVAL;
16+ }
1717
18- // Update endptr if provided
19- if (endptr != nullptr ) {
20- *endptr = const_cast <char *>(parse_result.ptr );
21- }
18+ // Update endptr if provided
19+ if (endptr != nullptr ) {
20+ *endptr = const_cast <char *>(parse_result.ptr );
21+ }
2222
23- return result;
23+ return result;
2424}
You can’t perform that action at this time.
0 commit comments