mirror of
https://github.com/fastfloat/fast_float.git
synced 2026-11-09 22:59:51 +08:00
Merge branch 'main' of https://github.com/fastfloat/fast_float
This commit is contained in:
commit
1d3332ec2d
2
.github/workflows/cifuzz.yml
vendored
2
.github/workflows/cifuzz.yml
vendored
@ -20,7 +20,7 @@ jobs:
|
|||||||
fuzz-seconds: 300
|
fuzz-seconds: 300
|
||||||
output-sarif: true
|
output-sarif: true
|
||||||
- name: Upload Crash
|
- name: Upload Crash
|
||||||
uses: actions/upload-artifact@v6
|
uses: actions/upload-artifact@v7
|
||||||
if: failure() && steps.build.outcome == 'success'
|
if: failure() && steps.build.outcome == 'success'
|
||||||
with:
|
with:
|
||||||
name: artifacts
|
name: artifacts
|
||||||
|
|||||||
2
.github/workflows/emscripten.yml
vendored
2
.github/workflows/emscripten.yml
vendored
@ -5,7 +5,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98 # v4.2.2
|
- uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98 # v4.2.2
|
||||||
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
|
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
|
||||||
- uses: mymindstorm/setup-emsdk@6ab9eb1bda2574c4ddb79809fc9247783eaf9021 # v14
|
- uses: mymindstorm/setup-emsdk@6ab9eb1bda2574c4ddb79809fc9247783eaf9021 # v14
|
||||||
- name: Verify
|
- name: Verify
|
||||||
run: emcc -v
|
run: emcc -v
|
||||||
|
|||||||
2
.github/workflows/lint_and_format_check.yml
vendored
2
.github/workflows/lint_and_format_check.yml
vendored
@ -27,7 +27,7 @@ jobs:
|
|||||||
- uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98 # v4.1.7
|
- uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98 # v4.1.7
|
||||||
|
|
||||||
- name: Run clang-format
|
- name: Run clang-format
|
||||||
uses: jidicula/clang-format-action@6cd220de46c89139a0365edae93eee8eb30ca8fe # v4.16.0
|
uses: jidicula/clang-format-action@3a18028048f01a66653b4e3bf8d968d2e7e2cb8b # v4.17.0
|
||||||
with:
|
with:
|
||||||
clang-format-version: '17'
|
clang-format-version: '17'
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
cmake_minimum_required(VERSION 3.14)
|
cmake_minimum_required(VERSION 3.14)
|
||||||
|
|
||||||
|
|
||||||
project(fast_float VERSION 8.2.3 LANGUAGES CXX)
|
project(fast_float VERSION 8.2.4 LANGUAGES CXX)
|
||||||
set(FASTFLOAT_CXX_STANDARD 11 CACHE STRING "the C++ standard to use for fastfloat")
|
set(FASTFLOAT_CXX_STANDARD 11 CACHE STRING "the C++ standard to use for fastfloat")
|
||||||
set(CMAKE_CXX_STANDARD ${FASTFLOAT_CXX_STANDARD})
|
set(CMAKE_CXX_STANDARD ${FASTFLOAT_CXX_STANDARD})
|
||||||
option(FASTFLOAT_TEST "Enable tests" OFF)
|
option(FASTFLOAT_TEST "Enable tests" OFF)
|
||||||
|
|||||||
11
README.md
11
README.md
@ -10,6 +10,9 @@
|
|||||||
[](https://github.com/irainman/fast_float/actions/workflows/vs17-clang-ci.yml)
|
[](https://github.com/irainman/fast_float/actions/workflows/vs17-clang-ci.yml)
|
||||||
[](https://www.codefactor.io/repository/github/irainman/fast_float)
|
[](https://www.codefactor.io/repository/github/irainman/fast_float)
|
||||||
|
|
||||||
|
*Note: This library is for C++ users. C programmers should consider [ffc.h](https://github.com/kolemannix/ffc.h). It is a high-performance port of fast_float to C.*
|
||||||
|
|
||||||
|
|
||||||
The fast_float library provides fast header-only implementations for the C++
|
The fast_float library provides fast header-only implementations for the C++
|
||||||
from_chars functions for `float` and `double` types as well as integer types.
|
from_chars functions for `float` and `double` types as well as integer types.
|
||||||
These functions convert ASCII strings representing decimal values (e.g.,
|
These functions convert ASCII strings representing decimal values (e.g.,
|
||||||
@ -17,6 +20,7 @@ These functions convert ASCII strings representing decimal values (e.g.,
|
|||||||
even). In our experience, these `fast_float` functions many times faster than
|
even). In our experience, these `fast_float` functions many times faster than
|
||||||
comparable number-parsing functions from existing C++ standard libraries.
|
comparable number-parsing functions from existing C++ standard libraries.
|
||||||
|
|
||||||
|
|
||||||
Specifically, `fast_float` provides the following two functions to parse
|
Specifically, `fast_float` provides the following two functions to parse
|
||||||
floating-point numbers with a C++17-like syntax (the library itself only
|
floating-point numbers with a C++17-like syntax (the library itself only
|
||||||
requires C++11):
|
requires C++11):
|
||||||
@ -531,6 +535,7 @@ Packages
|
|||||||
[Jackson](https://github.com/FasterXML/jackson-core).
|
[Jackson](https://github.com/FasterXML/jackson-core).
|
||||||
* [There is a C# port of the fast_float
|
* [There is a C# port of the fast_float
|
||||||
library](https://github.com/CarlVerret/csFastFloat) called `csFastFloat`.
|
library](https://github.com/CarlVerret/csFastFloat) called `csFastFloat`.
|
||||||
|
* [There is a plain C port of the fast_float library](https://github.com/kolemannix/ffc.h) called ffc.h
|
||||||
|
|
||||||
## How fast is it?
|
## How fast is it?
|
||||||
|
|
||||||
@ -579,7 +584,7 @@ sufficiently recent version of CMake (3.11 or better at least):
|
|||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
fast_float
|
fast_float
|
||||||
GIT_REPOSITORY https://github.com/fastfloat/fast_float.git
|
GIT_REPOSITORY https://github.com/fastfloat/fast_float.git
|
||||||
GIT_TAG tags/v8.2.3
|
GIT_TAG tags/v8.2.4
|
||||||
GIT_SHALLOW TRUE)
|
GIT_SHALLOW TRUE)
|
||||||
|
|
||||||
FetchContent_MakeAvailable(fast_float)
|
FetchContent_MakeAvailable(fast_float)
|
||||||
@ -595,7 +600,7 @@ You may also use [CPM](https://github.com/cpm-cmake/CPM.cmake), like so:
|
|||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
NAME fast_float
|
NAME fast_float
|
||||||
GITHUB_REPOSITORY "fastfloat/fast_float"
|
GITHUB_REPOSITORY "fastfloat/fast_float"
|
||||||
GIT_TAG v8.2.3)
|
GIT_TAG v8.2.4)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Using as single header
|
## Using as single header
|
||||||
@ -607,7 +612,7 @@ if desired as described in the command line help.
|
|||||||
|
|
||||||
You may directly download automatically generated single-header files:
|
You may directly download automatically generated single-header files:
|
||||||
|
|
||||||
<https://github.com/fastfloat/fast_float/releases/download/v8.2.3/fast_float.h>
|
<https://github.com/fastfloat/fast_float/releases/download/v8.2.4/fast_float.h>
|
||||||
|
|
||||||
## Benchmarking
|
## Benchmarking
|
||||||
|
|
||||||
|
|||||||
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
#define FASTFLOAT_VERSION_MAJOR 8
|
#define FASTFLOAT_VERSION_MAJOR 8
|
||||||
#define FASTFLOAT_VERSION_MINOR 2
|
#define FASTFLOAT_VERSION_MINOR 2
|
||||||
#define FASTFLOAT_VERSION_PATCH 3
|
#define FASTFLOAT_VERSION_PATCH 4
|
||||||
|
|
||||||
#define FASTFLOAT_STRINGIZE_IMPL(x) #x
|
#define FASTFLOAT_STRINGIZE_IMPL(x) #x
|
||||||
#define FASTFLOAT_STRINGIZE(x) FASTFLOAT_STRINGIZE_IMPL(x)
|
#define FASTFLOAT_STRINGIZE(x) FASTFLOAT_STRINGIZE_IMPL(x)
|
||||||
|
|||||||
@ -273,7 +273,7 @@ clinger_fast_path_impl(am_mant_t const mantissa, am_pow_t const exponent,
|
|||||||
* parsing options or other parsing custom function implemented by user.
|
* parsing options or other parsing custom function implemented by user.
|
||||||
*/
|
*/
|
||||||
template <typename T, typename UC>
|
template <typename T, typename UC>
|
||||||
FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC>
|
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC>
|
||||||
from_chars_advanced(parsed_number_string_t<UC> const &pns, T &value) noexcept {
|
from_chars_advanced(parsed_number_string_t<UC> const &pns, T &value) noexcept {
|
||||||
static_assert(is_supported_float_type<T>::value,
|
static_assert(is_supported_float_type<T>::value,
|
||||||
"only some floating-point types are supported");
|
"only some floating-point types are supported");
|
||||||
@ -319,7 +319,7 @@ from_chars_advanced(parsed_number_string_t<UC> const &pns, T &value) noexcept {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename UC>
|
template <typename T, typename UC>
|
||||||
FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC>
|
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC>
|
||||||
from_chars_float_advanced(UC const *first, UC const *last, T &value,
|
from_chars_float_advanced(UC const *first, UC const *last, T &value,
|
||||||
parse_options_t<UC> const options) noexcept {
|
parse_options_t<UC> const options) noexcept {
|
||||||
static_assert(is_supported_float_type<T>::value,
|
static_assert(is_supported_float_type<T>::value,
|
||||||
@ -532,7 +532,7 @@ template <size_t TypeIx> struct from_chars_advanced_caller {
|
|||||||
|
|
||||||
template <> struct from_chars_advanced_caller<1> {
|
template <> struct from_chars_advanced_caller<1> {
|
||||||
template <typename T, typename UC>
|
template <typename T, typename UC>
|
||||||
FASTFLOAT_CONSTEXPR20 static from_chars_result_t<UC>
|
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 static from_chars_result_t<UC>
|
||||||
call(UC const *first, UC const *last, T &value,
|
call(UC const *first, UC const *last, T &value,
|
||||||
parse_options_t<UC> const options) noexcept {
|
parse_options_t<UC> const options) noexcept {
|
||||||
return from_chars_float_advanced(first, last, value, options);
|
return from_chars_float_advanced(first, last, value, options);
|
||||||
@ -541,7 +541,7 @@ template <> struct from_chars_advanced_caller<1> {
|
|||||||
|
|
||||||
template <> struct from_chars_advanced_caller<2> {
|
template <> struct from_chars_advanced_caller<2> {
|
||||||
template <typename T, typename UC>
|
template <typename T, typename UC>
|
||||||
FASTFLOAT_CONSTEXPR20 static from_chars_result_t<UC>
|
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 static from_chars_result_t<UC>
|
||||||
call(UC const *first, UC const *last, T &value,
|
call(UC const *first, UC const *last, T &value,
|
||||||
parse_options_t<UC> const options) noexcept {
|
parse_options_t<UC> const options) noexcept {
|
||||||
return from_chars_int_advanced(first, last, value, options);
|
return from_chars_int_advanced(first, last, value, options);
|
||||||
@ -549,7 +549,7 @@ template <> struct from_chars_advanced_caller<2> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename T, typename UC>
|
template <typename T, typename UC>
|
||||||
FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC>
|
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC>
|
||||||
from_chars_advanced(UC const *first, UC const *last, T &value,
|
from_chars_advanced(UC const *first, UC const *last, T &value,
|
||||||
parse_options_t<UC> const options) noexcept {
|
parse_options_t<UC> const options) noexcept {
|
||||||
return from_chars_advanced_caller<
|
return from_chars_advanced_caller<
|
||||||
|
|||||||
@ -22,7 +22,7 @@ template <typename T> bool test() {
|
|||||||
char const *begin = input.data();
|
char const *begin = input.data();
|
||||||
char const *end = input.data() + input.size();
|
char const *end = input.data() + input.size();
|
||||||
for (size_t i = 0; i < answers.size(); i++) {
|
for (size_t i = 0; i < answers.size(); i++) {
|
||||||
T result_value;
|
T result_value = 0;
|
||||||
while ((begin < end) && (std::isspace(*begin))) {
|
while ((begin < end) && (std::isspace(*begin))) {
|
||||||
begin++;
|
begin++;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -98,7 +98,7 @@ template <typename T> bool test() {
|
|||||||
char const *begin = input.data();
|
char const *begin = input.data();
|
||||||
char const *end = input.data() + input.size();
|
char const *end = input.data() + input.size();
|
||||||
for (size_t i = 0; i < answers.size(); i++) {
|
for (size_t i = 0; i < answers.size(); i++) {
|
||||||
T result_value;
|
T result_value = 0;
|
||||||
while ((begin < end) && (std::isspace(*begin))) {
|
while ((begin < end) && (std::isspace(*begin))) {
|
||||||
begin++;
|
begin++;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user