WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
295 commits
Select commit Hold shift + click to select a range
3eaa7d7
compilation fix.
IRainman Mar 24, 2025
0340e8b
build fix.
IRainman Mar 24, 2025
edb51b3
.
IRainman Mar 24, 2025
922eaa1
Merge branch 'fastfloat:main' into main
IRainman Mar 27, 2025
67aeda0
Update README.md
IRainman Mar 27, 2025
82477e9
Update README.md
IRainman Mar 27, 2025
01e9d35
Tests updated and fixed.
IRainman Mar 28, 2025
a2d81d4
Merge branch 'main' of https://github.com/IRainman/fast_float
IRainman Mar 28, 2025
6687e73
Tests are updated.
IRainman Mar 28, 2025
34df2fc
Tests are updated.
IRainman Mar 28, 2025
8ebc89e
Reduce registers pressure.
IRainman Mar 28, 2025
fc9f61e
Cleanup initialization of the adjusted_mantissa.
IRainman Mar 28, 2025
ed87109
Remove FASTFLOAT_CONSTEVAL20 that I was added before and cleanup diff.
IRainman Mar 28, 2025
91e6c4d
.
IRainman Mar 28, 2025
afb54a5
Disable FASTFLOAT_ASSUME by default.
IRainman Mar 28, 2025
6aea2fb
initialization cleanup.
IRainman Mar 28, 2025
ee620a0
reduce registers pressure.
IRainman Mar 28, 2025
1651c2b
Readded FASTFLOAT_CONSTEVAL, but not used currently. Cleanup for FAST…
IRainman Apr 7, 2025
3faba01
Remove PVS.
IRainman Apr 7, 2025
4f0615b
Reduce register pressure and cleanup interface for standard.
IRainman Apr 7, 2025
8212e9e
fix warnings in the benchmark.
IRainman Apr 7, 2025
b261492
reduce register pressure.
IRainman Apr 7, 2025
a133b72
FASTFLOAT_ASSUME
IRainman Apr 8, 2025
b121f53
reduce register pressure.
IRainman Apr 8, 2025
5c61080
improvements of memory layout of parsed_number_string_t.
IRainman Apr 8, 2025
27f0265
style cleanup.
IRainman Apr 8, 2025
97bfec6
style fix.
IRainman Apr 8, 2025
b8f7771
after all sized checks is done I return the minimum registers size po…
IRainman Apr 8, 2025
f1b7f49
after all sized checks is done I return the minimum registers size po…
IRainman Apr 8, 2025
a591ca2
Merge branch 'main' of https://github.com/IRainman/fast_float
IRainman Apr 8, 2025
7c96e3a
reduce size of from_chars_result_t to 4 bytes. Cleanup for usage FAST…
IRainman Apr 9, 2025
a081ebe
reduce size of from_chars_result_t to 4 bytes. Cleanup for usage FAST…
IRainman Apr 9, 2025
8d4ca69
Merge branch 'main' of https://github.com/IRainman/fast_float
IRainman Apr 9, 2025
d32ae04
reduce size of from_chars_result_t to 4 bytes. Cleanup for usage FAST…
IRainman Apr 9, 2025
c762936
template interface cleanup for min_safe_u64 and max_digits_u64.
IRainman Apr 9, 2025
bbf4193
cleanup code generation for parse_mantissa.
IRainman Apr 9, 2025
2da25b5
trying to fix tests.
IRainman Apr 9, 2025
8e1fda5
fixes and cleanup for the parse_number_string function.
IRainman Apr 10, 2025
6cacae0
trying to fix tests.
IRainman Apr 10, 2025
68fe735
fix warnings.
IRainman Apr 10, 2025
f8625b6
fix warnings.
IRainman Apr 10, 2025
a4d1174
Merge branch 'main' of https://github.com/IRainman/fast_float
IRainman Apr 10, 2025
e71bfff
additional improve for debug runtime.
IRainman Apr 11, 2025
88b3887
benchmark cleanup.
IRainman Apr 11, 2025
563648f
* fix errors in the parse_number_string.
IRainman Apr 11, 2025
0daee75
# format
IRainman Apr 11, 2025
1aed8ee
try reordering again.
IRainman Apr 11, 2025
f3db77a
try reordering again.
IRainman Apr 11, 2025
b0bae17
* added chars_format_t for performance reason.
IRainman Apr 11, 2025
69fbbff
try additional part...
IRainman Apr 11, 2025
ba1344c
* carefully work with types in the library.
IRainman Apr 12, 2025
0a18d6b
# format.
IRainman Apr 12, 2025
17ffdff
* additional types cleanup for speedup and reduce cache pressure.
IRainman Apr 12, 2025
c99930b
added additional macro FASTFLOAT_ONLY_ROUNDS_TO_NEAREST_SUPPORTED for…
IRainman Apr 29, 2025
7bd3c54
benchmarks are updated.
IRainman Apr 29, 2025
4e230e8
benchmarks are updated.
IRainman Apr 29, 2025
d67876e
Merge branch 'main' of https://github.com/IRainman/fast_float
IRainman Apr 29, 2025
58cb366
Finally: after type refactoring is done give compiler opportunity to …
IRainman May 5, 2025
8721491
Finally: after type refactoring is done give compiler opportunity to …
IRainman May 5, 2025
8ccb587
Merge branch 'main' of https://github.com/IRainman/fast_float
IRainman May 5, 2025
103f220
Final functions call optimization.
IRainman May 5, 2025
5356317
Fix compilation for older standards
IRainman May 5, 2025
0ba4e20
lint
IRainman May 5, 2025
1febc3a
Fix compilation for older standards
IRainman May 5, 2025
a8c5bd9
warning fix.
IRainman May 5, 2025
9049a1a
clang-format.
IRainman May 6, 2025
c94d3a0
clang-format
IRainman May 6, 2025
b2ea7bc
clang-format
IRainman May 6, 2025
afbb803
compilation fixes for std::bfloat16_t and std::float16_t. Sorry for t…
IRainman May 6, 2025
d5c05e5
additional type usage fixes and constexpr.
IRainman May 6, 2025
99d769d
clang-format
IRainman May 6, 2025
66363cc
try to fix stupid shit in the tests, meh.
IRainman May 6, 2025
ba3f7a6
.
IRainman May 6, 2025
f2befa5
.
IRainman May 6, 2025
e5f1897
compilation fixes.
IRainman May 6, 2025
30bd959
Update msys2-clang.yml
IRainman May 6, 2025
c339618
Update msys2.yml
IRainman May 6, 2025
3f9e488
format, fuck.
IRainman May 6, 2025
a10b25f
Merge branch 'main' of https://github.com/IRainman/fast_float
IRainman May 6, 2025
a4c573e
compilation fix
IRainman May 6, 2025
a3ccc1f
compilation fix
IRainman May 6, 2025
e446899
compilation fix.
IRainman May 6, 2025
6f789de
compilation fix.
IRainman May 6, 2025
1ec5f08
compilation fix
IRainman May 6, 2025
036ba0d
compilation fix
IRainman May 6, 2025
568dfef
compilation fix
IRainman May 6, 2025
2f8ff9a
compilation fix
IRainman May 6, 2025
4b94a61
type usage fix
IRainman May 6, 2025
23a9c3f
review of the parse_number_string function: now it's much faster, saf…
IRainman May 7, 2025
f7d5037
fix for the parse_number_string
IRainman May 7, 2025
6b22957
fix for the parse_number_string
IRainman May 7, 2025
3ee80c2
fix for the parse_number_string
IRainman May 7, 2025
88fff01
fix for the parse_number_string
IRainman May 7, 2025
f14d482
fix for the parse_number_string
IRainman May 7, 2025
7bac324
fix for the parse_number_string
IRainman May 7, 2025
a550415
additional fix for bfloat16_t. Sorry, I can't compile it's locally.
IRainman May 7, 2025
978441a
additional FASTFLOAT_HAS_BIT_CAST improve for older standards.
IRainman May 7, 2025
437a80c
fix for type usage in parse_int_string
IRainman May 8, 2025
5ae2fba
cleanup for parse_number_string
IRainman May 10, 2025
4213171
compilation fix for internal tests
IRainman May 12, 2025
a72afb5
unfck clang format
IRainman May 12, 2025
acdcd04
Merge branch 'main' of https://github.com/fastfloat/fast_float
IRainman Jun 14, 2025
0cdbf36
Bump actions/checkout from 4 to 5 in the github-actions group
dependabot[bot] Aug 18, 2025
41dc71f
Merge branch 'fastfloat:main' into main
IRainman Aug 27, 2025
cd3118d
Merge pull request #2 from IRainman/dependabot/github_actions/github-…
IRainman Aug 27, 2025
af1f8e3
Merge branch 'main' of https://github.com/fastfloat/fast_float
IRainman Sep 15, 2025
e3aa994
# fix for stackvec constructor.
IRainman Sep 16, 2025
10970db
# cleanup
IRainman Sep 16, 2025
af8ece2
Merge branch 'main' of https://github.com/fastfloat/fast_float
IRainman Sep 18, 2025
3292820
* Readme updated.
IRainman Sep 18, 2025
097800a
# compilation fix after merge from upstream.
IRainman Sep 18, 2025
384fcec
# clang format
IRainman Sep 18, 2025
fe37628
# types fix after merge from upstream.
IRainman Sep 18, 2025
c7e0786
Update README.md
IRainman Sep 19, 2025
9f4be55
Bump the github-actions group across 1 directory with 3 updates
dependabot[bot] Oct 13, 2025
0f1a96a
Merge branch 'main' of https://github.com/fastfloat/fast_float
IRainman Oct 21, 2025
72e75ed
# compilation fix after merge.
IRainman Oct 21, 2025
240d393
# format
IRainman Oct 21, 2025
322e17b
Merge pull request #5 from IRainman/dependabot/github_actions/github-…
IRainman Oct 21, 2025
3288e56
# compilation fix after merge
IRainman Oct 21, 2025
4dcaf50
Merge branch 'main' of https://github.com/IRainman/fast_float
IRainman Oct 21, 2025
031f7fe
# tests are updated
IRainman Oct 21, 2025
1dc13a9
# improve checking for integer in the FASTFLOAT_ONLY_POSITIVE_C_NUMBE…
IRainman Oct 21, 2025
fe0bce5
# const and constexpr fixes
IRainman Oct 21, 2025
5a378ed
# minimize diff in the crutch.
IRainman Oct 21, 2025
0e123c5
# fix for digit_comp.
IRainman Oct 21, 2025
487799e
# cleanup and speedup digit_comp.
IRainman Oct 21, 2025
336b97d
# cleanup.
IRainman Oct 21, 2025
eee068d
# types fix.
IRainman Oct 21, 2025
1f0e281
# type usage fix.
IRainman Oct 21, 2025
58b5dc0
* Upgrade manually vectorized code to SSE4.2 for FASTFLOAT_64BIT beca…
IRainman Oct 21, 2025
f757eb4
* Upgrade manually vectorized code to support SSE4.2.
IRainman Oct 21, 2025
f396c23
* Upgrade manually vectorized code to support SSE4.2, final cleanup a…
IRainman Oct 21, 2025
397c0b8
# fix for FASTFLOAT_64BIT
IRainman Oct 21, 2025
1dfd486
# cleanup
IRainman Oct 21, 2025
57f63fc
* fix for parse_eight_digits_unrolled
IRainman Oct 21, 2025
6c175c5
# format
IRainman Oct 21, 2025
0c4171e
# small cleanup
IRainman Oct 21, 2025
5dc09e7
Bump the github-actions group across 1 directory with 3 updates
dependabot[bot] Nov 3, 2025
1d912b7
Merge pull request #7 from IRainman/dependabot/github_actions/github-…
IRainman Nov 8, 2025
625d9af
Merge branch 'main' of https://github.com/fastfloat/fast_float
IRainman Nov 8, 2025
f5dbaab
Merge branch 'main' of https://github.com/IRainman/fast_float
IRainman Nov 8, 2025
e35e6d2
Merge branch 'fastfloat:main' into main
IRainman Nov 8, 2025
97045b1
Merge branch 'main' of https://github.com/IRainman/fast_float
IRainman Nov 8, 2025
56d4233
* Improving in code generation -> speedup.
IRainman Nov 8, 2025
62b60e0
# Disable FASTFLOAT_HAS_BYTESWAP: step to try to fix precision error …
IRainman Nov 8, 2025
e6f2bf1
# test failed.
IRainman Nov 8, 2025
e96afe6
* try to fix precision error on x86 platform step2.
IRainman Nov 8, 2025
77ef468
* try to fix precision error on x86 platform step3.
IRainman Nov 8, 2025
578b1e9
* try to fix precision error on x86 platform step4.
IRainman Nov 8, 2025
cd62aad
* try to fix precision error on x86 platform step5.
IRainman Nov 8, 2025
df6b574
* try to fix precision error on x86 platform step6.
IRainman Nov 8, 2025
1ba0d48
* try to fix precision error on x86 platform step7.
IRainman Nov 8, 2025
97aa629
* try to fix precision error on x86 platform step8.
IRainman Nov 8, 2025
3e498bb
* try to fix precision error on x86 platform step9.
IRainman Nov 8, 2025
a92f025
* type usage fix
IRainman Nov 8, 2025
9e1d063
# tests
IRainman Nov 8, 2025
80902aa
* try to fix error on x86 platform step1.
IRainman Nov 9, 2025
50fa3ad
* code cleanup.
IRainman Nov 9, 2025
d0c7def
* try to fix error on x86 platform step2.
IRainman Nov 9, 2025
3ae6d3c
# unfck lint
IRainman Nov 9, 2025
e109eed
* try to fix error on x86 platform step3.
IRainman Nov 9, 2025
b9d91e7
* code cleanup.
IRainman Nov 9, 2025
959c953
# cycles (for and while) cleanup in low level for the best compiler o…
IRainman Nov 9, 2025
c8e4d89
# unfck lint
IRainman Nov 9, 2025
497e65b
* Added separate config macros FASTFLOAT_ISNOT_CHECKED_BOUNDS.
IRainman Nov 9, 2025
b816370
* type usage fix for better performance in any hardware.
IRainman Nov 9, 2025
597c239
# test fixed.
IRainman Nov 10, 2025
c9d0ac0
# cleanup.
IRainman Nov 10, 2025
843aa3f
* improvements in compiler function detection.
IRainman Nov 12, 2025
3685667
* FASTFLOAT_HAS_BIT_CAST cleanup.
IRainman Nov 19, 2025
3d46d99
# warning fix.
IRainman Nov 21, 2025
d697541
Merge branch 'main' of https://github.com/fastfloat/fast_float
IRainman Dec 4, 2025
077c6d0
Bump the github-actions group across 1 directory with 2 updates
dependabot[bot] Dec 8, 2025
7fd3d71
Merge branch 'fastfloat:main' into main
IRainman Dec 8, 2025
1cc96de
Merge branch 'main' of https://github.com/IRainman/fast_float
IRainman Dec 8, 2025
f4b821a
Merge pull request #9 from IRainman/dependabot/github_actions/github-…
IRainman Dec 8, 2025
588623e
* type usage fix for better performance in any hardware.
IRainman Dec 8, 2025
c54bafd
Merge branch 'main' of https://github.com/IRainman/fast_float
IRainman Dec 8, 2025
b79c3e5
Benchmark are updated.
IRainman Dec 9, 2025
47e181d
Bump the github-actions group with 2 updates
dependabot[bot] Dec 15, 2025
ac1e4dd
Merge branch 'main' of https://github.com/fastfloat/fast_float
IRainman Dec 24, 2025
b73ae25
Merge pull request #10 from IRainman/dependabot/github_actions/github…
IRainman Dec 24, 2025
65810eb
* enable warning in GCC because PVS-Studio are also detect this. This…
IRainman Dec 24, 2025
0838651
Merge branch 'main' of https://github.com/IRainman/fast_float
IRainman Dec 24, 2025
f42c880
* enable warning in GCC because PVS-Studio are also detect this. This…
IRainman Dec 24, 2025
600f236
* Small optimization in code generation for auto vectorization.
IRainman Dec 25, 2025
7041f91
Merge branch 'main' of https://github.com/fastfloat/fast_float
IRainman Dec 25, 2025
b7fb05b
* Added additional compile option FASTFLOAT_TABLE_HACK_CHAR_DIGIT_LUT…
IRainman Dec 25, 2025
2aba168
* optimize layout of the parsed_number_string_t.
IRainman Dec 25, 2025
a8c78f4
unfck lint.
IRainman Dec 25, 2025
e88d9ae
FASTFLOAT_HAS_BYTESWAP cleanup.
IRainman Dec 25, 2025
325c723
MSVC compilation fix.
IRainman Dec 25, 2025
9ff1624
small fix.
IRainman Dec 25, 2025
074fdea
small fix
IRainman Dec 25, 2025
be46835
fix for biodegradable code in doctest.
IRainman Dec 25, 2025
cdabfe4
# constexpr noexcept
IRainman Dec 25, 2025
d07362c
Final review for a more simple merge.
IRainman Dec 25, 2025
350ad6e
unfck lint
IRainman Dec 25, 2025
c119cdd
revert workflows.
IRainman Dec 25, 2025
0d36a01
Doctest DOCTEST_CONFIG_SUPER_FAST_ASSERTS
IRainman Dec 25, 2025
54d1f5a
fucking lint
IRainman Dec 25, 2025
5652a16
Update the Readme with fmt to the high performance example.
IRainman Dec 26, 2025
3ae10ee
Enhance README with compiler optimization details
IRainman Dec 26, 2025
8a518f4
am_pow_t is probably needs to be 64 bit because some hard coded value…
IRainman Dec 26, 2025
7ce5343
try again. need test refactoring.
IRainman Dec 26, 2025
6cefbb5
remove format.cmd: use IDE.
IRainman Dec 27, 2025
3745f4b
* documentation in the code updated, fixed errors with parsing some s…
IRainman Dec 27, 2025
2260580
fix compilation error in uint8_t parsing.
IRainman Dec 27, 2025
fb1e92c
code cleanup and type usage fixes.
IRainman Dec 27, 2025
812d89e
type usage fixes.
IRainman Dec 27, 2025
c1265cf
Merge branch 'main' of https://github.com/fastfloat/fast_float
IRainman Dec 28, 2025
62bc4b4
type usage fixes.
IRainman Dec 28, 2025
59c873d
cleanup.
IRainman Dec 28, 2025
5bc9637
type usage fixes.
IRainman Dec 28, 2025
5c6a6c2
type usage fixes.
IRainman Dec 28, 2025
8f49511
noexcept
IRainman Dec 28, 2025
489703f
type usage fixes.
IRainman Dec 28, 2025
37152ea
type usage fixes.
IRainman Dec 28, 2025
054004f
cleanup and type usage fixes.
IRainman Dec 28, 2025
ebc2ee8
optimization for the report_parse_error.
IRainman Dec 28, 2025
dad07cc
initialization cleanup and improve caches usage.
IRainman Dec 29, 2025
59da568
type usage fix.
IRainman Dec 29, 2025
5857b98
some warnings fix in CI builds.
IRainman Dec 29, 2025
a28e112
initialization cleanup.
IRainman Dec 29, 2025
38d0ab3
initialization cleanup.
IRainman Dec 29, 2025
147cf3b
type usage fix and cleanup.
IRainman Dec 29, 2025
351e4d3
type usage fixes.
IRainman Dec 29, 2025
35bca9c
type usage fixes.
IRainman Dec 29, 2025
0d42336
type usage fixes.
IRainman Dec 29, 2025
8330f85
type usage fixes.
IRainman Dec 29, 2025
611cd92
type usage fixes.
IRainman Dec 29, 2025
f4cae22
type usage fix.
IRainman Dec 29, 2025
9a0fa47
cleanup.
IRainman Dec 29, 2025
f556a68
cleanup.
IRainman Dec 29, 2025
41d9632
interface cleanup.
IRainman Dec 29, 2025
8f79501
* small cleanup in the tests/basictest.cpp
IRainman Dec 29, 2025
7ca9c84
type usage fixes.
IRainman Dec 29, 2025
f92d7fb
Merge branch 'main' of https://github.com/fastfloat/fast_float
IRainman Dec 29, 2025
2423180
cleanup
IRainman Dec 29, 2025
051d151
small performance improvement after full cleanup.
IRainman Dec 29, 2025
cd61547
FASTFLOAT_HAS_BIT_CAST fix for old standards.
IRainman Dec 29, 2025
fcdb586
cleanup in the API.
IRainman Dec 29, 2025
3d69a95
type usage fix.
IRainman Dec 29, 2025
f9bac93
type usage fix.
IRainman Dec 29, 2025
4910698
added compilation flags to the bench ip.
IRainman Dec 29, 2025
ba656ac
improvements in the code generation for byteswap and leading_zero to …
IRainman Dec 30, 2025
48abeeb
byteswap isn't compiling properly, no nay crutches that I try not hel…
IRainman Dec 30, 2025
61c7b53
small update for benchmark.
IRainman Dec 30, 2025
f5d44c7
compilation fix.
IRainman Dec 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 62 additions & 40 deletions include/fast_float/ascii_number.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ template <typename UC>
template <typename UC, FASTFLOAT_ENABLE_IF(!has_simd_opt<UC>()) = 0>
#endif
// dummy for compile
bool simd_parse_if_eight_digits_unrolled(UC const *, uint64_t &) {
FASTFLOAT_CONSTEVAL20 bool simd_parse_if_eight_digits_unrolled(UC const *, uint64_t &) {
return 0;
}

Expand Down Expand Up @@ -234,6 +234,7 @@ loop_parse_if_eight_digits(char const *&p, char const *const pend,

enum class parse_error {
no_error,
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
// [JSON-only] The minus sign must be followed by an integer.
missing_integer_after_sign,
// A sign must be followed by an integer or dot.
Expand All @@ -245,6 +246,7 @@ enum class parse_error {
// [JSON-only] If there is a decimal point, there must be digits in the
// fractional part.
no_digits_in_fractional_part,
#endif
// The mantissa must have at least one digit.
no_digits_in_mantissa,
// Scientific notation requires an exponential part.
Expand All @@ -255,7 +257,9 @@ template <typename UC> struct parsed_number_string_t {
int64_t exponent{0};
uint64_t mantissa{0};
UC const *lastmatch{nullptr};
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
bool negative{false};
#endif
bool valid{false};
bool too_many_digits{false};
// contains the range of the significant digits
Expand All @@ -269,7 +273,7 @@ using parsed_number_string = parsed_number_string_t<char>;

template <typename UC>
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 parsed_number_string_t<UC>
report_parse_error(UC const *p, parse_error error) {
report_parse_error(UC const *p, parse_error error) noexcept {
parsed_number_string_t<UC> answer;
answer.valid = false;
answer.lastmatch = p;
Expand All @@ -282,38 +286,39 @@ report_parse_error(UC const *p, parse_error error) {
template <typename UC>
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 parsed_number_string_t<UC>
parse_number_string(UC const *p, UC const *pend,
parse_options_t<UC> options) noexcept {
chars_format const fmt = detail::adjust_for_feature_macros(options.format);
UC const decimal_point = options.decimal_point;
const parse_options_t<UC> options) noexcept {

parsed_number_string_t<UC> answer;
answer.valid = false;
answer.too_many_digits = false;
// assume p < pend, so dereference without checks;
[[assume(p < pend)]]; // assume p < pend, so dereference without checks;
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
answer.negative = (*p == UC('-'));
// C++17 20.19.3.(7.1) explicitly forbids '+' sign here
if ((*p == UC('-')) ||
(uint64_t(fmt & chars_format::allow_leading_plus) &&
!uint64_t(fmt & detail::basic_json_fmt) && *p == UC('+'))) {
(uint64_t(options.format & chars_format::allow_leading_plus) &&
!uint64_t(options.format & detail::basic_json_fmt) && *p == UC('+'))) {
++p;
if (p == pend) {
return report_parse_error<UC>(
p, parse_error::missing_integer_or_dot_after_sign);
}
if (uint64_t(fmt & detail::basic_json_fmt)) {
if (uint64_t(options.format & detail::basic_json_fmt)) {
if (!is_integer(*p)) { // a sign must be followed by an integer
return report_parse_error<UC>(p,
parse_error::missing_integer_after_sign);
}
} else {
if (!is_integer(*p) &&
(*p !=
decimal_point)) { // a sign must be followed by an integer or the dot
options.decimal_point)) { // a sign must be followed by an integer or the dot
return report_parse_error<UC>(
p, parse_error::missing_integer_or_dot_after_sign);
}
}
}
#endif

UC const *const start_digits = p;

uint64_t i = 0; // an unsigned int avoids signed overflows (which are bad)
Expand All @@ -329,7 +334,8 @@ parse_number_string(UC const *p, UC const *pend,
UC const *const end_of_integer_part = p;
int64_t digit_count = int64_t(end_of_integer_part - start_digits);
answer.integer = span<UC const>(start_digits, size_t(digit_count));
if (uint64_t(fmt & detail::basic_json_fmt)) {
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
if (uint64_t(options.format & detail::basic_json_fmt)) {
// at least 1 digit in integer part, without leading zeros
if (digit_count == 0) {
return report_parse_error<UC>(p, parse_error::no_digits_in_integer_part);
Expand All @@ -339,9 +345,10 @@ parse_number_string(UC const *p, UC const *pend,
parse_error::leading_zeros_in_integer_part);
}
}
#endif

int64_t exponent = 0;
bool const has_decimal_point = (p != pend) && (*p == decimal_point);
bool const has_decimal_point = (p != pend) && (*p == options.decimal_point);
if (has_decimal_point) {
++p;
UC const *before = p;
Expand All @@ -358,22 +365,28 @@ parse_number_string(UC const *p, UC const *pend,
answer.fraction = span<UC const>(before, size_t(p - before));
digit_count -= exponent;
}
if (uint64_t(fmt & detail::basic_json_fmt)) {
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
if (uint64_t(options.format & detail::basic_json_fmt)) {
// at least 1 digit in fractional part
if (has_decimal_point && exponent == 0) {
return report_parse_error<UC>(p,
parse_error::no_digits_in_fractional_part);
}
} else if (digit_count ==
} else
#endif
if (digit_count ==
0) { // we must have encountered at least one integer!
return report_parse_error<UC>(p, parse_error::no_digits_in_mantissa);
}
int64_t exp_number = 0; // explicit exponential part
if ((uint64_t(fmt & chars_format::scientific) && (p != pend) &&
((UC('e') == *p) || (UC('E') == *p))) ||
(uint64_t(fmt & detail::basic_fortran_fmt) && (p != pend) &&
if ((uint64_t(options.format & chars_format::scientific) && (p != pend) &&
((UC('e') == *p) || (UC('E') == *p)))
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
|| (uint64_t(options.format & detail::basic_fortran_fmt) && (p != pend) &&
((UC('+') == *p) || (UC('-') == *p) || (UC('d') == *p) ||
(UC('D') == *p)))) {
(UC('D') == *p)))
#endif
) {
UC const *location_of_e = p;
if ((UC('e') == *p) || (UC('E') == *p) || (UC('d') == *p) ||
(UC('D') == *p)) {
Expand All @@ -389,7 +402,7 @@ parse_number_string(UC const *p, UC const *pend,
++p;
}
if ((p == pend) || !is_integer(*p)) {
if (!uint64_t(fmt & chars_format::fixed)) {
if (!uint64_t(options.format & chars_format::fixed)) {
// The exponential part is invalid for scientific notation, so it must
// be a trailing token for fixed notation. However, fixed notation is
// disabled, so report a scientific notation error.
Expand All @@ -412,8 +425,8 @@ parse_number_string(UC const *p, UC const *pend,
}
} else {
// If it scientific and not fixed, we have to bail out.
if (uint64_t(fmt & chars_format::scientific) &&
!uint64_t(fmt & chars_format::fixed)) {
if (uint64_t(options.format & chars_format::scientific) &&
!uint64_t(options.format & chars_format::fixed)) {
return report_parse_error<UC>(p, parse_error::missing_exponential_part);
}
}
Expand All @@ -431,7 +444,8 @@ parse_number_string(UC const *p, UC const *pend,
// We need to be mindful of the case where we only have zeroes...
// E.g., 0.000000000...000.
UC const *start = start_digits;
while ((start != pend) && (*start == UC('0') || *start == decimal_point)) {
while ((start != pend) && (*start == UC('0') ||
*start == options.decimal_point)) {
if (*start == UC('0')) {
digit_count--;
}
Expand Down Expand Up @@ -474,30 +488,30 @@ template <typename T, typename UC>
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC>
parse_int_string(UC const *p, UC const *pend, T &value,
parse_options_t<UC> options) {
chars_format const fmt = detail::adjust_for_feature_macros(options.format);
int const base = options.base;

from_chars_result_t<UC> answer;

UC const *const first = p;

#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
bool const negative = (*p == UC('-'));
#ifdef FASTFLOAT_VISUAL_STUDIO
#pragma warning(push)
#pragma warning(disable : 4127)
#endif
if (!std::is_signed<T>::value && negative) {
if (!std::is_signed<T>::value && negative) {
#ifdef FASTFLOAT_VISUAL_STUDIO
#pragma warning(pop)
#endif
answer.ec = std::errc::invalid_argument;
answer.ptr = first;
return answer;
}
if ((*p == UC('-')) ||
(uint64_t(fmt & chars_format::allow_leading_plus) && (*p == UC('+')))) {
++p;
}
answer.ec = std::errc::invalid_argument;
answer.ptr = first;
return answer;
}
if ((*p == UC('-')) ||
(uint64_t(options.fmt & chars_format::allow_leading_plus) && (*p == UC('+')))) {
++p;
}
#endif

UC const *const start_num = p;

Expand All @@ -510,15 +524,15 @@ parse_int_string(UC const *p, UC const *pend, T &value,
UC const *const start_digits = p;

uint64_t i = 0;
if (base == 10) {
if (options.base == 10) {
loop_parse_if_eight_digits(p, pend, i); // use SIMD if possible
}
while (p != pend) {
uint8_t digit = ch_to_digit(*p);
if (digit >= base) {
const uint8_t digit = ch_to_digit(*p);
if (digit >= options.base) {
break;
}
i = uint64_t(base) * i + digit; // might overflow, check this later
i = static_cast<uint64_t>(options.base) * i + digit; // might overflow, check this later
p++;
}

Expand All @@ -539,26 +553,31 @@ parse_int_string(UC const *p, UC const *pend, T &value,
answer.ptr = p;

// check u64 overflow
size_t max_digits = max_digits_u64(base);
size_t const max_digits = max_digits_u64(options.base);
if (digit_count > max_digits) {
answer.ec = std::errc::result_out_of_range;
return answer;
}
// this check can be eliminated for all other types, but they will all require
// a max_digits(base) equivalent
if (digit_count == max_digits && i < min_safe_u64(base)) {
if (digit_count == max_digits && i < min_safe_u64(options.base)) {
answer.ec = std::errc::result_out_of_range;
return answer;
}

// check other types overflow
if (!std::is_same<T, uint64_t>::value) {
if (i > uint64_t(std::numeric_limits<T>::max()) + uint64_t(negative)) {
if (i > uint64_t(std::numeric_limits<T>::max())
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
+ uint64_t(negative)
#endif
) {
answer.ec = std::errc::result_out_of_range;
return answer;
}
}

#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
if (negative) {
#ifdef FASTFLOAT_VISUAL_STUDIO
#pragma warning(push)
Expand All @@ -576,8 +595,11 @@ parse_int_string(UC const *p, UC const *pend, T &value,
#pragma warning(pop)
#endif
} else {
#endif
value = T(i);
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
}
#endif

answer.ec = std::errc();
return answer;
Expand Down
20 changes: 10 additions & 10 deletions include/fast_float/bigint.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ template <uint16_t size> struct stackvec {
// we never need more than 150 limbs
uint16_t length{0};

stackvec() = default;
FASTFLOAT_CONSTEXPR20 stackvec() noexcept = default;
stackvec(stackvec const &) = delete;
stackvec &operator=(stackvec const &) = delete;
stackvec(stackvec &&) = delete;
stackvec &operator=(stackvec &&other) = delete;

// create stack vector from existing limb span.
FASTFLOAT_CONSTEXPR20 stackvec(limb_span s) {
FASTFLOAT_CONSTEXPR20 stackvec(limb_span s) noexcept {
FASTFLOAT_ASSERT(try_extend(s));
}

Expand Down Expand Up @@ -435,14 +435,14 @@ struct bigint : pow5_tables<> {
// storage of the limbs, in little-endian order.
stackvec<bigint_limbs> vec;

FASTFLOAT_CONSTEXPR20 bigint() : vec() {}
FASTFLOAT_CONSTEXPR20 bigint() noexcept : vec() {}

bigint(bigint const &) = delete;
bigint &operator=(bigint const &) = delete;
bigint(bigint &&) = delete;
bigint &operator=(bigint &&other) = delete;

FASTFLOAT_CONSTEXPR20 bigint(uint64_t value) : vec() {
FASTFLOAT_CONSTEXPR20 bigint(uint64_t value) noexcept : vec() {
#ifdef FASTFLOAT_64BIT_LIMB
vec.push_unchecked(value);
#else
Expand Down Expand Up @@ -517,8 +517,8 @@ struct bigint : pow5_tables<> {
FASTFLOAT_DEBUG_ASSERT(n != 0);
FASTFLOAT_DEBUG_ASSERT(n < sizeof(limb) * 8);

size_t shl = n;
size_t shr = limb_bits - shl;
size_t const shl = n;
size_t const shr = limb_bits - shl;
limb prev = 0;
for (size_t index = 0; index < vec.len(); index++) {
limb xi = vec[index];
Expand Down Expand Up @@ -556,8 +556,8 @@ struct bigint : pow5_tables<> {

// move the limbs left by `n` bits.
FASTFLOAT_CONSTEXPR20 bool shl(size_t n) noexcept {
size_t rem = n % limb_bits;
size_t div = n / limb_bits;
size_t const rem = n % limb_bits;
size_t const div = n / limb_bits;
if (rem != 0) {
FASTFLOAT_TRY(shl_bits(rem));
}
Expand Down Expand Up @@ -598,8 +598,8 @@ struct bigint : pow5_tables<> {
// multiply as if by 5 raised to a power.
FASTFLOAT_CONSTEXPR20 bool pow5(uint32_t exp) noexcept {
// multiply by a power of 5
size_t large_length = sizeof(large_power_of_5) / sizeof(limb);
limb_span large = limb_span(large_power_of_5, large_length);
size_t const large_length = sizeof(large_power_of_5) / sizeof(limb);
limb_span const large = limb_span(large_power_of_5, large_length);
while (exp >= large_step) {
FASTFLOAT_TRY(large_mul(vec, large));
exp -= large_step;
Expand Down
2 changes: 2 additions & 0 deletions include/fast_float/constexpr_feature_detect.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@
defined(__cpp_lib_constexpr_algorithms) && \
__cpp_lib_constexpr_algorithms >= 201806L /*For std::copy and std::fill*/
#define FASTFLOAT_CONSTEXPR20 constexpr
#define FASTFLOAT_CONSTEVAL20 consteval
#define FASTFLOAT_IS_CONSTEXPR 1
#else
#define FASTFLOAT_CONSTEXPR20
#define FASTFLOAT_CONSTEVAL20
#define FASTFLOAT_IS_CONSTEXPR 0
#endif

Expand Down
2 changes: 1 addition & 1 deletion include/fast_float/decimal_to_binary.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace fast_float {
//
template <int bit_precision>
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 value128
compute_product_approximation(int64_t q, uint64_t w) {
compute_product_approximation(int64_t q, uint64_t w) noexcept {
int const index = 2 * int(q - powers::smallest_power_of_five);
// For small values of q, e.g., q in [0,27], the answer is always exact
// because The line value128 firstproduct = full_multiplication(w,
Expand Down
Loading