Compare commits

...

26 Commits
v8.2.3 ... main

Author SHA1 Message Date
Daniel Lemire
05087a303d 8.2.5 2026-04-16 14:39:03 -04:00
Daniel Lemire
b2b1e203ba removing msys 32-bit 2026-04-16 14:38:27 -04:00
Daniel Lemire
b57ec064ad
Merge pull request #379 from mlippautz/patch-1
Replace std::min with ternary operators to avoid <algorithm> dependency
2026-04-16 14:37:13 -04:00
Michael Lippautz
001c04cc8a Remove <algorithm> include and replace std::min with ternary operators
Replaces uses of std::min with ternary operators in ascii_number.h, digit_comparison.h, and float_common.h to remove the dependency on the <algorithm> header in those files.
2026-04-16 17:17:19 +00:00
Michael Lippautz
b063de82c7
Include <algorithm> in float_common.h
`fastfloat_strncasecmp` relies on `std::min`.
2026-04-16 09:51:58 +02:00
Daniel Lemire
d7ad33a80e
Merge pull request #377 from BYVoid/fix-bazel-bzlmod
Fix Bazel build with bzlmod
2026-03-27 09:37:23 -04:00
Carbo
2027a39ba0 Update MODULE.bazel version to 8.2.4
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 14:42:55 +09:00
Carbo
9817d5ddaa Fix Bazel build with bzlmod by loading cc_library rule
With bzlmod, native rules like cc_library are no longer implicitly available
and must be explicitly loaded from rules_cc. Add the rules_cc dependency to
MODULE.bazel and the corresponding load statement to BUILD.bazel.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 14:39:16 +09:00
Daniel Lemire
7124634005
Merge pull request #375 from fastfloat/dependabot/github_actions/github-actions-c571d227b7
Bump the github-actions group across 1 directory with 3 updates
2026-03-16 10:02:24 -04:00
dependabot[bot]
419695eba6
Bump the github-actions group across 1 directory with 3 updates
Bumps the github-actions group with 3 updates in the / directory: [actions/upload-artifact](https://github.com/actions/upload-artifact), [actions/setup-node](https://github.com/actions/setup-node) and [jidicula/clang-format-action](https://github.com/jidicula/clang-format-action).


Updates `actions/upload-artifact` from 6 to 7
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v6...v7)

Updates `actions/setup-node` from 6.2.0 to 6.3.0
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](6044e13b5d...53b83947a5)

Updates `jidicula/clang-format-action` from 4.16.0 to 4.17.0
- [Release notes](https://github.com/jidicula/clang-format-action/releases)
- [Commits](6cd220de46...3a18028048)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
- dependency-name: actions/setup-node
  dependency-version: 6.3.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-actions
- dependency-name: jidicula/clang-format-action
  dependency-version: 4.17.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-16 00:08:44 +00:00
Daniel Lemire
18e55e48a8 lint 2026-03-10 17:06:04 -04:00
Daniel Lemire
eb9ab42c0a 8.2.4 2026-03-10 12:10:12 -04:00
Daniel Lemire
50c19fad17 init 2026-03-10 11:53:45 -04:00
Daniel Lemire
3f42ad2272
Merge pull request #374 from kolemannix/bench_inline
A few inlines
2026-03-10 11:52:28 -04:00
Daniel Lemire
00fb4f4b1e
Merge pull request #372 from kolemannix/ffc_h_port
Mention C under other languages
2026-03-09 16:27:51 -04:00
Koleman Nix
2606bcdf2f A few inlines 2026-03-07 15:36:09 -05:00
Koleman Nix
b83fdd79ce consistency 2026-03-07 14:23:07 -05:00
Koleman Nix
a18b614b0e Mention C under other languages 2026-03-07 14:20:13 -05:00
Daniel Lemire
8514abe2e2
Update README with note for C users
Added a note for C users to consider ffc.h for high-performance parsing.
2026-03-05 21:59:09 -05:00
Daniel Lemire
9f30728ce9
Merge pull request #368 from x1sc0/main
fix warning C4702: unreachable code
2026-02-23 17:27:16 -05:00
Xisco Fauli
3c6a64b87d fix warning C4702: unreachable code 2026-02-06 11:28:34 +01:00
Daniel Lemire
221a4920db Merge branch 'main' of github.com:fastfloat/fast_float 2026-02-04 12:13:47 -05:00
Daniel Lemire
a110aa1392 adding bug report template 2026-02-04 12:13:25 -05:00
Daniel Lemire
8d9f627710
Merge pull request #366 from 976520/main
Add more boundary test cases for double and float parsing
2026-02-04 10:55:44 -05:00
재욱
3e2b5d3dc3 refactor verification calls for double and float limits 2026-02-04 15:36:31 +09:00
재욱
f43d6711bc Add additional verification cases for double and float limits 2026-02-04 15:27:46 +09:00
17 changed files with 70 additions and 36 deletions

24
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@ -0,0 +1,24 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Ideally, you should provide a reproducible test case.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Additional context**
Add any other context about the problem here.
**Note:** Bug reports should come with a test case or, at least, an analysis.
**Automated tool policy**: If you use an automated tool (e.g., static analysis,
LLM, etc.), you need to demonstrate an understanding of the issue you are raising. Usually, a bug is demonstrated by a test case. Do not copy-paste what a tool is telling you.

View File

@ -20,7 +20,7 @@ jobs:
fuzz-seconds: 300
output-sarif: true
- name: Upload Crash
uses: actions/upload-artifact@v6
uses: actions/upload-artifact@v7
if: failure() && steps.build.outcome == 'success'
with:
name: artifacts

View File

@ -5,7 +5,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- 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
- name: Verify
run: emcc -v

View File

@ -27,7 +27,7 @@ jobs:
- uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98 # v4.1.7
- name: Run clang-format
uses: jidicula/clang-format-action@6cd220de46c89139a0365edae93eee8eb30ca8fe # v4.16.0
uses: jidicula/clang-format-action@3a18028048f01a66653b4e3bf8d968d2e7e2cb8b # v4.17.0
with:
clang-format-version: '17'

View File

@ -16,9 +16,6 @@ jobs:
- msystem: "MINGW64"
install: mingw-w64-x86_64-libxml2 mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja mingw-w64-x86_64-clang
type: Release
- msystem: "MINGW32"
install: mingw-w64-i686-libxml2 mingw-w64-i686-cmake mingw-w64-i686-ninja mingw-w64-i686-clang
type: Release
env:
CMAKE_GENERATOR: Ninja

View File

@ -16,15 +16,9 @@ jobs:
- msystem: "MINGW64"
install: mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja mingw-w64-x86_64-gcc
type: Release
- msystem: "MINGW32"
install: mingw-w64-i686-cmake mingw-w64-i686-ninja mingw-w64-i686-gcc
type: Release
- msystem: "MINGW64"
install: mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja mingw-w64-x86_64-gcc
type: Debug
- msystem: "MINGW32"
install: mingw-w64-i686-cmake mingw-w64-i686-ninja mingw-w64-i686-gcc
type: Debug
env:
CMAKE_GENERATOR: Ninja

View File

@ -1,3 +1,5 @@
load("@rules_cc//cc:cc_library.bzl", "cc_library")
cc_library(
name = "fast_float",
hdrs = glob(["include/fast_float/*.h"]),

View File

@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.14)
project(fast_float VERSION 8.2.3 LANGUAGES CXX)
project(fast_float VERSION 8.2.5 LANGUAGES CXX)
set(FASTFLOAT_CXX_STANDARD 11 CACHE STRING "the C++ standard to use for fastfloat")
set(CMAKE_CXX_STANDARD ${FASTFLOAT_CXX_STANDARD})
option(FASTFLOAT_TEST "Enable tests" OFF)

View File

@ -2,8 +2,10 @@
module(
name = "fast_float",
version = "6.1.6",
compatibility_level = 6,
version = "8.2.4",
compatibility_level = 8,
)
bazel_dep(name = "doctest", version = "2.4.11", dev_dependency = True)
bazel_dep(name = "rules_cc", version = "0.2.17")

View File

@ -3,6 +3,9 @@
[![Ubuntu 22.04 CI (GCC 11)](https://github.com/fastfloat/fast_float/actions/workflows/ubuntu22.yml/badge.svg)](https://github.com/fastfloat/fast_float/actions/workflows/ubuntu22.yml)
*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++
from_chars functions for `float` and `double` types as well as integer types.
These functions convert ASCII strings representing decimal values (e.g.,
@ -10,6 +13,7 @@ These functions convert ASCII strings representing decimal values (e.g.,
even). In our experience, these `fast_float` functions many times faster than
comparable number-parsing functions from existing C++ standard libraries.
Specifically, `fast_float` provides the following two functions to parse
floating-point numbers with a C++17-like syntax (the library itself only
requires C++11):
@ -488,6 +492,7 @@ Packages
[Jackson](https://github.com/FasterXML/jackson-core).
* [There is a C# port of the fast_float
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?
@ -536,7 +541,7 @@ sufficiently recent version of CMake (3.11 or better at least):
FetchContent_Declare(
fast_float
GIT_REPOSITORY https://github.com/fastfloat/fast_float.git
GIT_TAG tags/v8.2.3
GIT_TAG tags/v8.2.5
GIT_SHALLOW TRUE)
FetchContent_MakeAvailable(fast_float)
@ -552,7 +557,7 @@ You may also use [CPM](https://github.com/cpm-cmake/CPM.cmake), like so:
CPMAddPackage(
NAME fast_float
GITHUB_REPOSITORY "fastfloat/fast_float"
GIT_TAG v8.2.3)
GIT_TAG v8.2.5)
```
## Using as single header
@ -564,7 +569,7 @@ if desired as described in the command line help.
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.5/fast_float.h>
## Benchmarking

View File

@ -594,7 +594,7 @@ parse_int_string(UC const *p, UC const *pend, T &value,
((digits + 0x46464646u) | (digits - 0x30303030u)) & 0x80808080u;
uint32_t tz = (uint32_t)countr_zero_32(magic); // 7, 15, 23, 31, or 32
uint32_t nd = (tz == 32) ? 4 : (tz >> 3);
nd = (uint32_t)std::min((size_t)nd, len);
nd = (uint32_t)(nd < len ? nd : len);
if (nd == 0) {
if (has_leading_zeros) {
value = 0;

View File

@ -1,7 +1,6 @@
#ifndef FASTFLOAT_DIGIT_COMPARISON_H
#define FASTFLOAT_DIGIT_COMPARISON_H
#include <algorithm>
#include <cstdint>
#include <cstring>
#include <iterator>
@ -109,7 +108,7 @@ fastfloat_really_inline FASTFLOAT_CONSTEXPR14 void round(adjusted_mantissa &am,
if (-am.power2 >= mantissa_shift) {
// have a denormal float
int32_t shift = -am.power2 + 1;
cb(am, std::min<int32_t>(shift, 64));
cb(am, (shift < 64 ? shift : 64));
// check for round-up: if rounding-nearest carried us to the hidden bit.
am.power2 = (am.mantissa <
(uint64_t(1) << binary_format<T>::mantissa_explicit_bits()))

View File

@ -18,7 +18,7 @@
#define FASTFLOAT_VERSION_MAJOR 8
#define FASTFLOAT_VERSION_MINOR 2
#define FASTFLOAT_VERSION_PATCH 3
#define FASTFLOAT_VERSION_PATCH 5
#define FASTFLOAT_STRINGIZE_IMPL(x) #x
#define FASTFLOAT_STRINGIZE(x) FASTFLOAT_STRINGIZE_IMPL(x)
@ -313,8 +313,6 @@ fastfloat_strncasecmp3(UC const *actual_mixedcase,
return false;
}
}
return true;
}
template <typename UC>
@ -369,8 +367,6 @@ fastfloat_strncasecmp5(UC const *actual_mixedcase,
return false;
}
}
return true;
}
// Compares two ASCII strings in a case insensitive manner.
@ -402,7 +398,7 @@ fastfloat_strncasecmp(UC const *actual_mixedcase, UC const *expected_lowercase,
size_t sz{8 / (sizeof(UC))};
for (size_t i = 0; i < length; i += sz) {
val1 = val2 = 0;
sz = std::min(sz, length - i);
sz = sz < (length - i) ? sz : length - i;
::memcpy(&val1, actual_mixedcase + i, sz * sizeof(UC));
::memcpy(&val2, expected_lowercase + i, sz * sizeof(UC));
val1 |= mask;

View File

@ -155,7 +155,7 @@ template <> struct from_chars_caller<std::float32_t> {
// if std::float32_t is defined, and we are in C++23 mode; macro set for
// float32; set value to float due to equivalence between float and
// float32_t
float val;
float val = 0.0f;
auto ret = from_chars_advanced(first, last, val, options);
value = val;
return ret;
@ -172,7 +172,7 @@ template <> struct from_chars_caller<std::float64_t> {
// if std::float64_t is defined, and we are in C++23 mode; macro set for
// float64; set value as double due to equivalence between double and
// float64_t
double val;
double val = 0.0;
auto ret = from_chars_advanced(first, last, val, options);
value = val;
return ret;
@ -251,7 +251,7 @@ clinger_fast_path_impl(uint64_t mantissa, int64_t exponent, bool is_negative,
* parsing options or other parsing custom function implemented by user.
*/
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> &pns, T &value) noexcept {
static_assert(is_supported_float_type<T>::value,
"only some floating-point types are supported");
@ -290,7 +290,7 @@ from_chars_advanced(parsed_number_string_t<UC> &pns, T &value) noexcept {
}
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,
parse_options_t<UC> options) noexcept {
@ -456,7 +456,7 @@ template <size_t TypeIx> struct from_chars_advanced_caller {
template <> struct from_chars_advanced_caller<1> {
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,
parse_options_t<UC> options) noexcept {
return from_chars_float_advanced(first, last, value, options);
@ -465,7 +465,7 @@ template <> struct from_chars_advanced_caller<1> {
template <> struct from_chars_advanced_caller<2> {
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,
parse_options_t<UC> options) noexcept {
return from_chars_int_advanced(first, last, value, options);
@ -473,7 +473,7 @@ template <> struct from_chars_advanced_caller<2> {
};
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,
parse_options_t<UC> options) noexcept {
return from_chars_advanced_caller<

View File

@ -1167,6 +1167,9 @@ TEST_CASE("double.general") {
// DBL_TRUE_MIN / 2 + 0.0000000000000001e-324
verify("2.4703282292062328e-324", 0x0.0000000000001p-1022);
verify("0.2470328229206232720e-323", 0.0, std::errc::result_out_of_range);
verify("0.2470328229206232721e-323", 0x0.0000000000001p-1022);
verify("-2.2222222222223e-322", -0x1.68p-1069);
verify("9007199254740993.0", 0x1p+53);
verify("860228122.6654514319E+90", 0x1.92bb20990715fp+328);
@ -1262,8 +1265,13 @@ TEST_CASE("double.general") {
verify("4.9406564584124654e-324", 0x0.0000000000001p-1022);
verify("2.2250738585072009e-308", 0x0.fffffffffffffp-1022);
verify("2.2250738585072014e-308", 0x1p-1022);
verify("0.2225073858507201136e-307", 0x0.fffffffffffffp-1022);
verify("0.2225073858507201137e-307", 0x1p-1022);
verify("1.7976931348623157e308", 0x1.fffffffffffffp+1023);
verify("1.7976931348623158e308", 0x1.fffffffffffffp+1023);
verify("1.7976931348623158079e308", std::numeric_limits<double>::max());
verify("1.7976931348623158080e308", std::numeric_limits<double>::infinity(),
std::errc::result_out_of_range);
verify("4503599627370496.5", 4503599627370496.5);
verify("4503599627475352.5", 4503599627475352.5);
verify("4503599627475353.5", 4503599627475353.5);
@ -1543,6 +1551,8 @@ TEST_CASE("float.general") {
verify("0.7006492e-45", 0.f, std::errc::result_out_of_range);
// FLT_TRUE_MIN / 2 + 0.0000001e-45
verify("0.7006493e-45", 0x1p-149f);
verify("0.7006492321624085354e-45", 0.f, std::errc::result_out_of_range);
verify("0.7006492321624085355e-45", 0x1p-149f);
// max
verify("340282346638528859811704183484516925440", 0x1.fffffep+127f);
@ -1553,6 +1563,9 @@ TEST_CASE("float.general") {
// that rounds to FLT_MAX
verify("340282356779733661637539395458142568447",
std::numeric_limits<float>::max());
verify("0.3402823567797336616e39", std::numeric_limits<float>::max());
verify("0.3402823567797336617e39", std::numeric_limits<float>::infinity(),
std::errc::result_out_of_range);
verify("-1e-999", -0.0f, std::errc::result_out_of_range);
verify("1."
@ -1563,6 +1576,8 @@ TEST_CASE("float.general") {
"175494140627517859246175898662808184331245864732796240031385942718174"
"6759860647699724722770042717456817626953125e-38",
0x1.fffff8p-127f);
verify("1.1754942807573642917e-38", 0x1.fffffcp-127f);
verify("1.1754942807573642918e-38", std::numeric_limits<float>::min());
verify_runtime(
append_zeros("1."
"17549414062751785924617589866280818433124586473279624003138"

View File

@ -22,7 +22,7 @@ template <typename T> bool test() {
char const *begin = input.data();
char const *end = input.data() + input.size();
for (size_t i = 0; i < answers.size(); i++) {
T result_value;
T result_value = 0;
while ((begin < end) && (std::isspace(*begin))) {
begin++;
}

View File

@ -98,7 +98,7 @@ template <typename T> bool test() {
char const *begin = input.data();
char const *end = input.data() + input.size();
for (size_t i = 0; i < answers.size(); i++) {
T result_value;
T result_value = 0;
while ((begin < end) && (std::isspace(*begin))) {
begin++;
}