Daniel Lemire
12ece3c84f
removing leftover print
2024-01-28 15:20:41 -05:00
Daniel Lemire
a0ea962bf5
more fixes
2024-01-28 15:18:40 -05:00
Daniel Lemire
eb584f748e
explicit cast
2024-01-28 13:29:55 -05:00
Daniel Lemire
9da74ca5fb
minor fixes
2024-01-28 12:49:00 -05:00
Daniel Lemire
fade2357ba
fix missing typename
2024-01-28 11:46:27 -05:00
Daniel Lemire
c7e45fea9f
Merge pull request #229 from MTahaK/main
...
Support for float32_t and float64_t
2024-01-28 11:43:54 -05:00
Daniel Lemire
1d97749791
Verify and fix issue 235
2024-01-28 10:47:21 -05:00
Daniel Lemire
620376ad39
Merge branch 'main' into main
2024-01-28 10:09:56 -05:00
Darrell Wright
b43f808190
Update float_common.h
...
The construct !! is a no-op for a bool, op< for uint64_t's. Removed it and made it an explicit cast to match the operations being performed
2023-12-27 19:43:56 -05:00
Maya Warrier
882a716c12
Explicit curly bracket where suggested
...
Co-authored-by: Daniel Lemire <daniel@lemire.me>
2023-12-14 16:28:23 -05:00
Maya Warrier
a59a62cb5c
Merge branch 'fastfloat:main' into main
2023-12-13 17:54:05 -05:00
Maya Warrier
bdee16bcad
- Add SIMD acceleration to fast_int
...
- fix MSVC warning
2023-12-13 17:42:30 -05:00
Maya Warrier
36aaded3dd
Fix handling of leading zeros
2023-12-13 17:11:41 -05:00
Maya Warrier
1e0a9da538
Change FASTLOAT_ARM64 macro to FASTFLOAT_NEON
2023-12-13 00:56:35 -05:00
MTahaK
96c0059fe9
Revised implementation of float32_t and float64_t support as template specializations, added test
2023-12-13 00:33:16 -05:00
Maya Warrier
a30fe866f6
Fix bugs highlighted in tests
2023-12-12 22:35:58 -05:00
Maya Warrier
624ba49434
Fix more Werrors
...
- Werror=conversion,char-subscripts
2023-12-12 21:26:48 -05:00
MTahaK
4d8a2f4000
Fixed typo.
2023-12-12 19:02:10 -05:00
MTahaK
f330ec1e9d
Reverted CMakeLists changes, modifed workflow for g++13 & C++23.
2023-12-12 18:59:59 -05:00
MTahaK
d10980bc9f
Added conditions to include stdfloat, and new workflow for GCC 13
2023-12-12 18:46:38 -05:00
MTahaK
62a4129a1c
Fixed ifdef macro
2023-12-12 18:18:13 -05:00
MTahaK
eb844a1ad9
Modified cmakelist to use C++23. Fixed ifdef for fixed-width float types
2023-12-12 18:16:27 -05:00
MTahaK
cbbbc75c88
Fixed ifdef checks (incorrect syntax)
2023-12-12 17:59:04 -05:00
MTahaK
d8dbbc54ab
Updated comment for float32_t and float64_t conversions in from_chars
2023-12-12 17:56:14 -05:00
MTahaK
f74e338e0a
Added trivial support for float32_t and float64_t
2023-12-12 16:38:48 -05:00
Maya Warrier
7a21a8d6d7
Return invalid_argument in more places
2023-12-12 02:36:18 -05:00
Maya Warrier
3d446f1eba
Fix gcc werrors
2023-12-12 01:56:24 -05:00
Maya Warrier
c9527c2e4f
Skip leading zeros
2023-12-11 04:27:22 -05:00
Maya Warrier
122220e2f0
Version 1 of from_chars integer parser
2023-12-11 04:17:26 -05:00
Daniel Lemire
35d523195b
Merge pull request #225 from fastfloat/fix_win32_ci
...
fix for 32-bit Visual Studio when not set to round to nearest
2023-11-27 16:21:01 -05:00
Daniel Lemire
fda97168f0
casting to avoid warnings
2023-11-27 15:50:47 -05:00
Daniel Lemire
70d8e0ad0e
In some cases, Visual Studio, when compiling 32-bit binaries, gets
...
0*something == -0 even when the 'something' is positive, when the system
is not set to compile to nearest.
2023-11-27 15:44:24 -05:00
Antoine Cœur
c325db1b04
float_common.h:237:52 Value stored to 'input_num' is never read
2023-11-25 18:45:15 +01:00
Daniel Lemire
7646f819a8
Merge branch 'main' of github.com:allenbarnett5/fast_float_ftn into fortran
2023-09-15 09:43:27 -04:00
Maya Warrier
7b1fc2f95d
Add an option to allow inf/nan even in json mode
...
- Most JSON parsers offer this option too
2023-09-14 21:07:22 -04:00
Maya Warrier
ce562d9c65
Disallow inf/nan in json mode
2023-09-14 20:51:26 -04:00
Maya Warrier
2395482ad5
Ignore FASTFLOAT_ALLOWS_LEADING_PLUS for JSON format
2023-09-14 19:50:21 -04:00
Maya Warrier
4de8d715e6
Add json fmt test
2023-09-13 21:07:40 -04:00
Maya Warrier
3f250c5a98
Use chars_format instead of parse_rules for parsing as JSON
2023-09-13 20:03:10 -04:00
Maya Warrier
396f41271f
Implement JSON rules
2023-09-13 19:19:37 -04:00
allen.barnett@paperbirchsoftware.com
e22c027544
Allow fast_float to parse strings accepted by the Fortran internal read
...
function.
2023-08-07 08:39:06 -04:00
deadalnix
5167a5029d
Change smallest_power_of_ten to -64 for floats.
...
`18446744073709551615e-65` rounds to `0`, and it is the largest possible value with exponent `-65`. Therefore, we can assume the minimal exponent for which we don't round to zero actually is `-64`.
2023-07-12 14:27:46 +00:00
Cœur
3e90425e3c
code review: FASTFLOAT_CONSTEXPR14
2023-06-12 22:27:31 +02:00
Cœur
f5f64e46cd
float_common.h: fix possible misuse of comma operator
2023-06-12 21:05:51 +02:00
Maya Warrier
c5ecb5db9b
Fix for MSVC v140
2023-06-11 22:22:06 -04:00
Daniel Lemire
c80ff7c18a
Merge pull request #212 from fastfloat/issue211
...
Renaming the using for the local type.
2023-06-10 10:49:03 -04:00
Daniel Lemire
a14f8c587e
Fix.
2023-06-10 10:48:46 -04:00
Daniel Lemire
eea6fef9a1
tweak
2023-06-10 09:47:48 -04:00
Daniel Lemire
ba328bbf7d
Renaming the using for the local type.
2023-06-10 09:44:49 -04:00
Pharago
b8e3307fbd
Fix broken msvc v140
...
When using msvc v140 (Visual Studio 2015 Toolset), compilation fails.
2023-06-10 05:46:30 +02:00
Daniel Lemire
3cab724b80
Minor fixes
2023-06-09 12:30:20 -04:00
Daniel Lemire
b88345d06d
Fixes
2023-06-09 11:28:51 -04:00
Daniel Lemire
e8c0378d6d
Adding ARM NEON optimizations.
2023-06-09 11:19:34 -04:00
Daniel Lemire
8139e164b8
Merge pull request #198 from mayawarrier/main
...
Add opt-in SIMD support for char16_t
2023-06-09 10:40:04 -04:00
v1gnesh
bb2ae14fe6
Add zOS support to float_common.h
2023-06-05 19:16:46 +05:30
zangruochen
fcee052311
Support LoongArch64
2023-05-30 15:16:27 +08:00
Maya Warrier
a5632d5b57
Fix digit comparison, cleanup
2023-05-20 12:29:24 -04:00
Maya Warrier
cb397ef446
Fix for clang (missing _mm_cvtsi128_si64x)
2023-05-17 05:40:29 -04:00
Maya Warrier
1c9a3088bf
Fix for VS 32-bit
2023-05-17 05:31:15 -04:00
Maya Warrier
064d2b832d
Fix Werrors
2023-05-17 02:27:48 -04:00
Maya Warrier
38613a39f9
Fix perf decrease when UC = char
2023-05-17 01:34:33 -04:00
Maya Warrier
6ede038789
Apply changes from benchmarked version
...
- Move parse_truncated_number_string back inside parse_number_string
2023-05-09 22:19:23 -04:00
Daniel Lemire
396a0fc2ae
Merge branch 'main' into main
2023-05-08 16:44:35 -04:00
Daniel Lemire
cc1e01e9ee
Merge pull request #199 from mayawarrier/cmake_intellisense_fix
...
Fix for broken VS Intellisense
2023-05-08 16:43:45 -04:00
Lenard Szolnoki
ddaefc0bbf
Fix multiple definition linker errors for tables
2023-05-08 15:24:11 +01:00
Lenard Szolnoki
cc042ae409
Make lookup tables external linkage
2023-05-07 23:07:34 +01:00
Maya Warrier
53b065f38d
Avoid redundant load in SSE2 code
2023-05-07 17:38:32 -04:00
Maya Warrier
4e7ae339d6
Implement intellisense fix
2023-05-07 00:38:10 -04:00
Maya Warrier
4cb09b5f59
Automatically detect SSE2
2023-05-02 13:05:57 -04:00
Maya Warrier
c811b027ea
Remove testing macro
2023-05-02 01:52:00 -04:00
Maya Warrier
5136b181ba
Fixes and cleanup
2023-05-02 01:41:49 -04:00
Maya Warrier
680ccc73ed
Merge from upstream/main, fix conflicts
2023-05-01 20:27:29 -04:00
Maya Warrier
e08c55c380
Remove json parse rules/allow inf_nan
2023-05-01 19:45:50 -04:00
Maya Warrier
091458d192
Add basic support for char32_t (unoptimized)
2023-04-30 02:23:33 -04:00
Daniel Lemire
8199baeb70
Slightly less ugly code.
2023-04-26 18:46:19 -04:00
Daniel Lemire
225df8c934
Merge branch 'fastfloat:main' into other_chars
2023-04-26 18:32:06 -04:00
Daniel Lemire
5223d7a460
address issues raised by @mayawarrier
2023-04-26 18:25:27 -04:00
Maya Warrier
65bd922e38
Merge remote-tracking branch 'upstream/main'
...
- Fix conflicts
2023-04-26 16:47:42 -04:00
Daniel Lemire
927eb9bcd2
Merge branch 'main' of https://github.com/Pharago/fast_float into other_chars
2023-04-26 16:40:09 -04:00
Maya Warrier
89fc24007a
Clean up
2023-04-26 16:25:41 -04:00
Maya Warrier
653790b5f3
fixes
2023-04-16 00:36:52 -04:00
Maya Warrier
c849b7a8ff
Option to forbid nan/inf, refactor
2023-04-15 23:16:01 -04:00
Daniel Lemire
11eeab5463
Removing dead code.
2023-04-11 14:29:30 -04:00
Pharago
ece3b3886b
Fix storage class errors on non msvc builds
...
Removed storage class declarations from explicit template specializations of string constants
2023-04-06 20:58:31 +02:00
Pharago
2bfbe4ca96
cosmetic changes
2023-04-06 00:58:34 +02:00
Pharago
593709f056
Merge branch 'main' into main
2023-04-05 03:31:35 +02:00
Aras Pranckevičius
21fefa5b44
Fix warnings with -Wundef
...
- FASTFLOAT_ALLOWS_LEADING_PLUS and FASTFLOAT_SKIP_WHITE_SPACE are not defined by default, and compiling with -Wundef is emitting warnigns like "FASTFLOAT_ALLOWS_LEADING_PLUS is not defined, evaluates to 0".
- Likewise for FASTFLOAT_VISUAL_STUDIO, change checks to use #ifdef for that like in other places.
- __cpp_lib_bit_cast and __cpp_lib_is_constant_evaluated are not defined pre-C++20, and are emitting a warning too.
2023-04-04 21:18:57 +03:00
Pharago
148606637c
Merge branch 'fastfloat:main' into main
2023-04-03 02:25:46 +02:00
Daniel Lemire
ca43e6722e
We need to update some of our exhaustive tests to the new API
2023-04-02 17:43:17 -04:00
Pharago
bc77f956e2
Initial Unicode release
...
Added support for the other char types
2023-04-02 22:58:01 +02:00
Maya Warrier
cda25408bc
Optimize char16_t parsing for digit_comparison.h
2023-04-02 00:33:52 -04:00
Maya Warrier
2d57c09530
Fixes
2023-04-01 23:29:00 -04:00
Maya Warrier
8a9a9d538a
SIMD optimization to parse 8 char16_t at a time
2023-04-01 22:43:00 -04:00
Maya Warrier
f59f73c4da
Disable simd-related warnings
2023-04-01 04:09:00 -04:00
Maya Warrier
20f3870361
Fixes
2023-03-30 04:58:22 -04:00
Maya Warrier
2b118c843a
Experimental support for char_t types
2023-03-30 04:48:18 -04:00
Maya Warrier
b6acf38a2e
Fix bugs
2023-03-29 18:42:24 -04:00
Adam Lugowski
bfee511d78
Set errc::result_out_of_range on over/underflow
...
Best-effort values are still returned, such as 0 for underflow and infinity for overflow, but now the returned ec is set to std::errc::result_out_of_range instead of std::errc().
2023-03-29 10:14:46 -07:00
Maya Warrier
3cafcca2ff
Add support for json parsing rules and integers
2023-03-29 02:14:12 -04:00
Maya Warrier
8f94758c78
Expose parsed string (before computation) so it can be reused
2023-03-27 22:50:21 -04:00
Daniel Lemire
b50a729d93
Merge pull request #182 from leni536/constexpr-from_chars
...
Constexpr from_chars
2023-03-25 17:30:55 -04:00
Lenard Szolnoki
5b8290433c
Fix clang workaround for parsing -0 on non-nearest rounding mode
2023-03-25 19:38:44 +00:00
Lenard Szolnoki
e464bd7785
Replace memmove with copy_backward
2023-03-24 17:18:58 +00:00
Lenard Szolnoki
d34d0d7405
Fix amalgamate.ph and add header for constexpr macros
2023-03-12 10:50:25 +00:00
filipecosta90
c8886eb31d
Added missing FASTFLOAT_ALLOWS_LEADING_PLUS ifdef check in parse_infnan
2023-03-07 00:31:14 +00:00
Lenard Szolnoki
e05858a0f8
Work around clang bug.
...
https://godbolt.org/z/zedh7rrhc
This is similar to https://github.com/llvm/llvm-project/issues/47746 ,
except I needed to use a different workaround.
2023-03-04 23:02:15 +00:00
Lenard Szolnoki
6732e397d8
Add constexpr testing
...
When enabled, modify `verify` macro to also verify at compile time,
when the arguments are constant expressions.
2023-03-04 22:36:58 +00:00
Lenard Szolnoki
e4d4e43b21
Constexpr from_chars
2023-03-04 20:53:43 +00:00
Lenard Szolnoki
82ee3b1b5f
Constexpr parse_number_string
2023-03-04 17:18:25 +00:00
Lenard Szolnoki
5243dd97fe
Constexpr bigint
2023-03-03 23:13:52 +00:00
Lenard Szolnoki
52618851fd
Make all float_common.h functions constexpr in C++20
2023-03-03 22:43:52 +00:00
Lenard Szolnoki
6d2fb68f5c
Simplify to_float
...
* Use right-sized uint type for bit fiddling
** This removes the need to special casing on endianness
* Replace ternary with just shifting the sign at the right place
** This seems to improve codegen (less instructions, no cmov)
2023-03-01 23:39:01 +00:00
Daniel Lemire
b1d27734c5
Merge pull request #173 from fastfloat/nofallbacknecessary
...
We do not need a fallback.
2023-02-28 17:19:57 -05:00
Lenard Szolnoki
e320512755
Fix power_of_five_128 to be usable in constexpr in MSVC, clang
2023-02-25 18:34:22 +00:00
Lenard Szolnoki
0e4b873d81
Fix space_lut so it's accepted by MSVC and clang
2023-02-25 18:27:10 +00:00
Lenard Szolnoki
a6991ea44f
Add comment to the FASTFLOAT_CONSTEXPR14 macro definition
2023-02-25 11:11:09 +00:00
Lenard Szolnoki
be6084863c
Low-risk C++14 constexpr functions
2023-02-25 10:50:45 +00:00
Daniel Lemire
252a1c9dce
Minor fix.
2023-02-06 17:22:11 -05:00
Daniel Lemire
39e04ea766
We do not need a fallback.
2023-01-27 20:59:56 -05:00
Daniel Lemire
3e2da540ef
Support rccpfastfloat.
2023-01-19 20:28:10 -05:00
Sergey Fedorov
ff7fba01d0
float_common.h: add support for ppc32
2023-01-18 14:15:14 +08:00
Daniel Lemire
c8aac4a63d
Guard endian
2023-01-07 13:28:12 -05:00
Joao Paulo Magalhaes
7f7838b36a
Fix compile warning: implicit double->float type conversion
...
With Intel 2021.1:
```
/home/runner/work/c4core/c4core/src/c4/ext/fast_float_all.h:319:49: error: implicit conversion between floating point types of different sizes [-Werror,-Wimplicit-float-size-conversion]
constexpr static float powers_of_ten_float[] = {1e0, 1e1, 1e2, 1e3,
1e4, 1e5,
```
2022-12-27 11:09:17 +00:00
Joao Paulo Magalhaes
ca13367ff7
Suppress warning when comparing floats
2022-12-27 01:39:41 +00:00
Daniel Lemire
102e74891f
Merge pull request #160 from huangqinjin/uint64-to-bool
...
Fix compile warning of unit64_t to bool
2022-12-23 10:39:33 -05:00
huangqinjin
293ca61c76
Fix compile warning of unit64_t to bool
2022-12-23 19:20:28 +08:00
huangqinjin
9c4c20dd7f
Replace utf8 chars.
2022-12-18 11:04:16 +08:00
Sutou Kouhei
ff5855813f
Add missing namespace end comments
...
Other files have it.
2022-12-02 11:42:38 +09:00
Daniel Lemire
76537e1695
Fixing issue 154.
2022-11-25 15:58:54 -05:00
Daniel Lemire
003a983188
Simplifying the justification.
2022-11-18 15:38:21 -05:00
Daniel Lemire
8b7a55a03c
Minor optimization.
2022-11-18 15:33:44 -05:00
Daniel Lemire
3d0e448940
Added a remark.
2022-11-18 12:27:38 -05:00
Daniel Lemire
39ea41b84a
Adopting proposal.
2022-11-18 11:28:34 -05:00
Daniel Lemire
bfc0478feb
More tweaks.
2022-11-16 16:45:01 -05:00
Daniel Lemire
29b1a03d5b
Make sure that macros have actual values when defined (makes debugging easier)
2022-11-16 15:49:09 -05:00
Daniel Lemire
8f27b7e921
More tuning.
2022-11-16 15:42:56 -05:00
Daniel Lemire
fd9d9effda
More tweaking around clangcl
2022-11-16 15:25:03 -05:00
Daniel Lemire
d225059873
Fix for Win32+ClangCL
2022-11-16 14:35:31 -05:00
Daniel Lemire
2c8e738950
Cleaning.
2022-11-16 12:06:33 -05:00
Daniel Lemire
6ceb29a7e4
We might reenable clinger.
2022-11-16 16:21:34 +00:00
Daniel Lemire
6484c73696
Trimming out one eight-digit optimization.
2022-11-15 11:38:06 -05:00
Daniel Lemire
a2cf502395
Typo.
2022-11-03 19:41:30 -04:00
Daniel Lemire
3e29bf78c7
Nicer constants.
2022-11-03 19:40:05 -04:00
Daniel Lemire
e958ff4269
Simplified clinger.
2022-11-03 18:51:37 -04:00
Sutou Kouhei
5a71e5bc40
Don't use __umulh() with MinGW on ARM64
2022-10-28 15:33:37 +09:00
Dirk Stolle
3fddb89508
Fix some typos
2022-08-30 22:55:34 +02:00
Daniel Lemire
6876616f0f
Update float_common.h
2022-08-04 15:05:22 -04:00
Daniel Lemire
ac81b01696
Added __EMSCRIPTEN__ patch
2022-08-04 13:58:48 -04:00
Daniel Lemire
32d21dcecb
Merge pull request #122 from jwakely/patch-1
...
Fix deduction failure for std::min call
2022-01-18 14:30:38 -05:00
Jonathan Wakely
61f4840188
Make endianness detection more portable
...
The current check for endianness fails on platforms using newlib as the
C library, because it provides <machine/endian.h> not <endian.h>. This
could be fixed by adding `|| defined(__NEWLIB__)` to the check for
targets that provide <machine/endian.h> (i.e. BSD-like targets).
A more portable solution is to just check if the compiler has already
defined the necessary macros (which is true for GCC and Clang and Intel,
at least). Then no header is needed, and it works for platforms that
aren't explicitly listed in the conditionals.
2022-01-18 10:17:01 +00:00
Jonathan Wakely
1ccabed64c
Fix deduction failure for std::min call
...
This assumes that the literal `64` of type `int` has the same type as
the `int32_t` typedef, which is never true for targets with 16-bit
`int`, and isn't guaranteed to be true even with 32-bit `int`.
2022-01-18 10:12:57 +00:00
Antoine Pitrou
133099ab4e
Fix #117 : compilation warning with gcc 6.3.0
...
Fix the following warning:
```
/arrow/cpp/src/arrow/vendored/fast_float/digit_comparison.h:62:50: error: right shift count >= width of type [-Werror=shift-count-overflow]
am.power2 = int32_t((bits & exponent_mask) >> binary_format<T>::mantissa_explicit_bits());
~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
2021-11-30 20:35:09 +01:00
Daniel Lemire
d148241404
Removing CXX20 support
2021-09-20 09:49:23 -04:00
Daniel Lemire
b334317dd2
Minor fixes
2021-09-14 21:31:34 -04:00
Alex Huszagh
fc0c8680a5
Implement the big-integer arithmetic algorithm.
...
Replaces the existing decimal implementation, for substantial
performance improvements with near-halfway cases. This is especially
fast with a large number of digits.
**Big Integer Implementation**
A small subset of big-integer arithmetic has been added, with the
`bigint` struct. It uses a stack-allocated vector with enough bits to
store the float with the large number of significant digits. This is
log2(10^(769 + 342)), to account for the largest possible magnitude
exponent, and number of digits (3600 bits), and then rounded up to 4k bits.
The limb size is determined by the architecture: most 64-bit
architectures have efficient 128-bit multiplication, either by a single
hardware instruction or 2 native multiplications for the high and low
bits. This includes x86_64, mips64, s390x, aarch64, powerpc64, riscv64,
and the only known exception is sparcv8 and sparcv9. Therefore, we
define a limb size of 64-bits on 64-bit architectures except SPARC,
otherwise we fallback to 32-bit limbs.
A simple stackvector is used, which just has operations to add elements,
index, and truncate the vector.
`bigint` is then just a wrapper around this, with methods for
big-integer arithmetic. For our algorithms, we just need multiplication
by a power (x * b^N), multiplication by a bigint or scalar value, and
addition by a bigint or scalar value. Scalar addition and multiplication
uses compiler extensions when possible (__builtin_add_overflow and
__uint128_t), if not, then we implement simple logic shown to optimize
well on MSVC. Big-integer multiplication is done via grade school
multiplication, which is more efficient than any asymptotically faster
algorithms. Multiplication by a power is then done via bitshifts for
powers-of-two, and by iterative multiplications of a large and then
scalar value for powers-of-5.
**compute_float**
Compute float has been slightly modified so if the algorithm cannot
round correctly, it returns a normalized, extended-precision adjusted
mantissa with the power2 shifted by INT16_MIN so the exponent is always
negative. `compute_error` and `compute_error_scaled` have been added.
**Digit Optimiations**
To improve performance for numbers with many digits,
`parse_eight_digits_unrolled` is used for both integers and fractions,
and uses a while loop than two nested if statements. This adds no
noticeable performance cost for common floats, but dramatically improves
performance for numbers with large digits (without these optimizations,
~65% of the total runtime cost is in parse_number_string).
**Parsed Number**
Two fields have been added to `parsed_number_string`, which contains a
slice of the integer and fraction digits. This is extremely cheap, since
the work is already done, and the strings are pre-tokenized during
parsing. This allows us on overflow to re-parse these tokenized strings,
without checking if each character is an integer. Likewise, for the
big-integer algorithms, we can merely re-parse the pre-tokenized
strings.
**Slow Algorithm**
The new algorithm is `digit_comp`, which takes the parsed number string
and the `adjusted_mantissa` from `compute_float`. The significant digits
are parsed into a big integer, and the exponent relative to the
significant digits is calculated. If the exponent is >= 0, we use
`positive_digit_comp`, otherwise, we use `negative_digit_comp`.
`positive_digit_comp` is quite simple: we scale the significant digits
to the exponent, and then we get the high 64-bits for the native float,
determine if any lower bits were truncated, and use that to direct
rounding.
`negative_digit_comp` is a little more complex, but also quite trivial:
we use the parsed significant digits as the real digits, and calculate
the theoretical digits from `b+h`, the halfway point between `b` and
`b+u`, the next-positive float. To get `b`, we round the adjusted
mantissa down, create an extended-precision representation, and
calculate the halfway point. We now have a base-10 exponent for the real
digits, and a base-2 exponent for the theoretical digits. We scale these
two to the same exponent by multiplying the theoretixal digits by
`5**-real_exp`. We then get the base-2 exponent as `theor_exp -
real_exp`, and if this is positive, we multipy the theoretical digits by
it, otherwise, we multiply the real digits by it. Now, both are scaled
to the same magnitude, and we simply compare the digits in the big
integer, and use that to direct rounding.
**Rust-Isms**
A few Rust-isms have been added, since it simplifies logic assertions.
These can be trivially removed or reworked, as needed.
- a `slice` type has been added, which is a pointer and length.
- `FASTFLOAT_ASSERT`, `FASTFLOAT_DEBUG_ASSERT`, and `FASTFLOAT_TRY` have
been added
- `FASTFLOAT_ASSERT` aborts, even in release builds, if the condition
fails.
- `FASTFLOAT_DEBUG_ASSERT` defaults to `assert`, for logic errors.
- `FASTFLOAT_TRY` is like a Rust `Option` type, which propagates
errors.
Specifically, `FASTFLOAT_TRY` is useful in combination with
`FASTFLOAT_ASSERT` to ensure there are no memory corruption errors
possible in the big-integer arithmetic. Although the `bigint` type
ensures we have enough storage for all valid floats, memory issues are
quite a severe class of vulnerabilities, and due to the low performance
cost of checks, we abort if we would have out-of-bounds writes. This can
only occur when we are adding items to the vector, which is a very small
number of steps. Therefore, we abort if our memory safety guarantees
ever fail. lexical has never aborted, so it's unlikely we will ever fail
these guarantees.
2021-09-10 18:53:53 -05:00
Jonas Rahlf
162a37b25a
remove cstdio includes, remove cassert include, add asthetic newlines
2021-09-05 23:13:41 +02:00
Jonas Rahlf
4e13ec151b
check for HAS_CXX20_CONSTEXPR before attempting to do c++20 stuff
2021-09-02 23:20:28 +02:00
Jonas Rahlf
e5d5e576a6
use #if defined __has_include properly
2021-09-02 22:22:03 +02:00
Jonas Rahlf
b17eafd06f
chnage compiler check for bit_cast so it compiles with older compilers
2021-09-02 22:00:57 +02:00
Jonas Rahlf
d8ee88e7f6
initial version with working constexpr for c++20 compliant compilers
2021-09-01 00:52:25 +02:00
Alex Huszagh
3e74ed313a
Fixes #94 , with unspecified behavior in pointer comparisons.
2021-08-21 13:07:57 -05:00
Antoine Pitrou
3881ea6937
Issue #90 : accept custom decimal point
2021-08-03 10:44:24 +02:00
Daniel Lemire
94c78adb2e
Typo
2021-06-07 10:34:44 -04:00
Daniel Lemire
93a2c79cf2
Adding m_arm detection.
2021-06-07 10:27:52 -04:00
Daniel Lemire
f54b41c09e
Tweak for 32-bit Windows
2021-06-07 09:14:09 -04:00
Daniel Lemire
06e61729c9
making constexpr as inline.
2021-06-01 09:46:43 -04:00
Alex Huszagh
b712b6f9a5
Add support for other architectures.
2021-05-24 11:37:38 -05:00
Alex Huszagh
49ca5d855e
Added 8-digit optimizations to big endian.
2021-05-23 21:47:40 -05:00
Daniel Lemire
19a771c615
Using out-of-line definition.
2021-04-08 10:46:43 -04:00
Daniel Lemire
2cbfc21f8a
Avoiding internal name conflict.
2021-04-07 13:39:07 -04:00
Daniel Lemire
a8d49f40f0
This uses the template trick to ensure we get only one definition
2021-04-07 13:34:53 -04:00
Marcin Wojdyr
f21b2f24cb
change anonymous namespace to namespace detail ( #54 )
2021-04-07 15:17:37 +02:00
Eugene Golushkov
87e5a95585
Prevent fast_float::from_chars from parsing whitespaces and leading '+' sign, similar to MSVC and integer LLVM std::from_chars behavior. See C++17 20.19.3.(7.1) and http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0067r5.html
2021-03-04 20:21:45 +02:00
Tim Paine
48d30f789b
add support for missing flag on emscripten
2021-03-01 22:43:57 -05:00
Eugene Golushkov
76dec80fbd
Parse "nan(n-char-seq-opt)" as required by C++17 20.19.3.7 and C11 7.20.1.3.3. At least MSVC produces nan(ind) and nan(snan), and according to https://reviews.llvm.org/D70631 MSVC implementation seems to became LLVM std::to_chars().
2021-03-01 20:21:33 +02:00
Daniel Lemire
9d76b043c5
Minor typo.
2021-02-26 11:21:20 -05:00
Neal Richardson
ca0a4646e9
Locate endian header on Solaris
2021-02-17 13:46:04 -08:00
Daniel Lemire
716c87067e
Simplifying fix.
2021-01-11 11:24:54 -05:00
Daniel Lemire
c5adf9e4a5
Fix truncate flag.
2021-01-11 11:22:00 -05:00
Daniel Lemire
cf1a4ec2f5
Further tweaking.
2021-01-08 10:09:26 -05:00
Daniel Lemire
192b271c12
Removing dead code
2021-01-07 18:03:33 -05:00
Daniel Lemire
cad8cfdf57
Removing dead code.
2021-01-07 18:01:57 -05:00
Daniel Lemire
a27fcc230d
This should be mostly correct.
2021-01-07 17:46:47 -05:00
Daniel Lemire
ca51b646c8
Update float_common.h
2021-01-07 16:44:39 -05:00
Daniel Lemire
002966323c
Update float_common.h
2021-01-07 16:44:07 -05:00
Daniel Lemire
51b27a3324
Trying alternate handling of overflows.
2020-12-31 11:14:48 -05:00
Daniel Lemire
47ffc1303b
Removing spurious 's'.
2020-12-29 15:29:46 -05:00
Daniel Lemire
a7d15fd6d0
Fixes https://github.com/fastfloat/fast_float/issues/47
2020-12-29 13:22:37 -05:00
Daniel Lemire
a1a7347464
Minor tweaks to better handle cygwin/clang.
2020-12-22 15:55:48 -05:00
Joao Paulo Magalhaes
e65f977135
fix: never include iostream unless it's absolutely necessary
2020-11-24 00:24:17 +00:00
Daniel Lemire
7ef9d9b7d2
Tweaking cast.
2020-11-23 15:04:48 -05:00
Daniel Lemire
86bc73af9e
Need explicit cast.
2020-11-23 13:53:50 -05:00
Daniel Lemire
426dd2a4a6
Merge branch 'main' into dlemire/aqrit_magic
2020-11-23 13:48:06 -05:00
Daniel Lemire
4583e75e3e
Merge branch 'main' into dlemire/extended_fast_path
2020-11-22 13:10:07 -05:00
Joao Paulo Magalhaes
037136a966
fix: add bitness for ppc64le
2020-11-21 19:01:26 +00:00
Joao Paulo Magalhaes
ed6664d93e
add bitness for s390
2020-11-21 09:08:11 +01:00
Daniel Lemire
7bf5db7216
Tuning.
2020-11-20 17:05:06 -05:00
Daniel Lemire
8fde4bad4e
Adding a guard.
2020-11-20 16:09:53 -05:00
Joao Paulo Magalhaes
9afc814fb6
tidy float_common.h: put feature test macros at the top
2020-11-20 09:44:27 +00:00
Joao Paulo Magalhaes
bfa33b3ed1
fix mingw compile errors
2020-11-20 00:48:21 +00:00
Joao Paulo Magalhaes
f7b13da349
fix: readjust full_multiplication() and leading_zeroes() on windows
2020-11-20 00:48:20 +00:00
Joao Paulo Magalhaes
5ce64de524
fix: full 64bit multiplication working on 32bit gcc/clang
2020-11-20 00:48:20 +00:00
Joao Paulo Magalhaes
8a04a06a88
leading_zeroes(): 0 is not a valid input
2020-11-20 00:48:20 +00:00
Joao Paulo Magalhaes
449c628645
__emulu() is needed for mingw32
2020-11-20 00:48:19 +00:00
Joao Paulo Magalhaes
c4693cc86f
re #33 : win32 is working
2020-11-20 00:48:19 +00:00
Joao Paulo Magalhaes
829ac72f87
re #33 : 32bit version. gcc compiles successfully, fails tests.
2020-11-20 00:48:19 +00:00
Daniel Lemire
d521ddf7f7
Let us adjust the powers instead.
2020-11-19 18:15:42 -05:00
Daniel Lemire
1afba556e3
Extending the fast path.
2020-11-17 21:55:01 -05:00
Daniel Lemire
1b5e3f3945
patching be support. (typo)
2020-11-16 12:56:57 -05:00
Daniel Lemire
7ff364b59a
This might add support for big endian systems (untested).
2020-11-16 12:04:57 -05:00
Daniel Lemire
8a0a0c4fc1
Being pedantic.
2020-11-15 14:51:54 -05:00
Daniel Lemire
e5917323ec
Pedantic member initialization.
2020-11-15 14:47:43 -05:00
Daniel Lemire
e79741ede2
Minor cleaning.
2020-11-12 22:35:32 -05:00
Daniel Lemire
1e92d59997
Sign conversion pedantry.
2020-11-11 20:43:36 -05:00
Daniel Lemire
9c5dac3705
Build with pedantic flags under GNU GCC.
2020-11-11 20:17:18 -05:00
Daniel Lemire
689fba95b5
Minor simplification.
2020-11-10 20:38:23 -05:00
Daniel Lemire
58faaac627
Adding another remark.
2020-11-09 20:23:38 -05:00
Daniel Lemire
d26a697a4d
Added remark.
2020-11-09 20:22:45 -05:00
Daniel Lemire
41ee34701b
Magical optimizations from @aqrit
2020-11-09 19:06:51 -05:00
Daniel Lemire
cd8f09885b
Removing possibly misleading comment.
2020-11-09 18:34:46 -05:00
Daniel Lemire
9a424bde1e
Reverting a microoptimization.
2020-11-09 09:51:35 -05:00
Daniel Lemire
045a0b0447
Merge pull request #24 from kitaisreal/fix-odr
...
Fixed odr with inlining and anonymous namespace
2020-11-09 09:48:49 -05:00
Maksim Kita
68633178d5
Fixed odr with inlining and anonymous namespace
2020-11-08 15:20:11 +03:00
Daniel Lemire
51f813a987
Tweaking.
2020-11-07 16:28:49 -05:00
Daniel Lemire
e3fd438c64
Tweaking.
2020-11-07 16:27:53 -05:00
Daniel Lemire
693fa66fa4
More testing.
2020-11-06 17:28:55 -05:00
Daniel Lemire
dcc883cde8
Merge branch 'main' of github.com:lemire/fast_float into main
2020-11-05 22:58:29 -05:00
Daniel Lemire
afd255b58b
Minor update.
2020-11-05 22:58:19 -05:00
Daniel Lemire
4e076c70f9
Merge pull request #18 from lemire/dlemire/minor_styling
...
Fixing minor style issues.
2020-11-05 19:04:59 -05:00
Daniel Lemire
741e68ce61
Fixes https://github.com/lemire/fast_float/issues/19
2020-11-05 16:32:19 -05:00
Daniel Lemire
9b102a95ab
Actually, 19.
2020-11-02 21:46:31 -05:00
Daniel Lemire
288efd35eb
Minor cleaning.
2020-11-02 21:42:01 -05:00
Daniel Lemire
078095d1e3
Patching.
2020-11-02 20:17:11 -05:00
Daniel Lemire
83154a24ad
Fixing minor style issues.
2020-11-02 14:55:17 -05:00
Daniel Lemire
48c017aa96
Rounded toward one, not zero.
2020-10-31 10:40:05 -04:00
Daniel Lemire
022118e5d0
Minor logical fix.
2020-10-30 14:56:15 -04:00
Daniel Lemire
26ecdea26c
Fixing comment.
2020-10-30 11:39:31 -04:00
Daniel Lemire
71e0355de8
fixing a comment.
2020-10-29 16:54:35 -04:00
Daniel Lemire
e8e1a01733
cout
2020-10-29 16:47:33 -04:00
Daniel Lemire
f7d3cdc426
Minor fix.
2020-10-29 16:40:20 -04:00
Daniel Lemire
70bb48c5c1
Update simple_decimal_conversion.h
2020-10-27 21:39:47 -04:00
Daniel Lemire
47d3d443d8
Minor fix.
2020-10-27 21:26:11 -04:00
Daniel Lemire
8559cfa73f
Some optimization.
2020-10-27 21:11:19 -04:00
Daniel Lemire
c53bfc4176
Minor tweak.
2020-10-27 20:10:42 -04:00
Daniel Lemire
eb1103393e
Minor tuning.
2020-10-27 19:34:21 -04:00
Daniel Lemire
05ad45dfb5
Let us try the long path.
2020-10-27 18:26:16 -04:00
Daniel Lemire
644b05989d
Merge pull request #14 from lemire/dlemire/issue9
...
issue 9
2020-10-27 16:27:58 -04:00
Daniel Lemire
7ec9b70dcf
Fixing https://github.com/lemire/fast_float/issues/9
2020-10-27 16:10:48 -04:00
Daniel Lemire
390eed3b03
Mising file.
2020-10-27 16:06:54 -04:00
Daniel Lemire
dad0ee3a8f
Renaming
2020-10-27 16:05:09 -04:00