-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ryu-like String to Float Parsing (#138)
A limited implementation for up to 17-digit numbers. See #129. * Move some d2s intrinsics to d2s_intrinsics.h * Rudimentary string to double parsing * Implement more pieces for parsing - parse exponents - parse dot - handle negative exponents - handle rounding - add some basic tests for these things * Fix constants * Use __builtin_clzll Thanks to expnkx for finding this. See #133. * Allow exponent to start with '+' * Correctly handle mantissa overflow * Increase the table size Denormal numbers require a larger table because the decimal exponent can go down to -326 (we're using the table inversely to how it's originally used for shortest). * Handle most overflow/underflow situations * Increase table size some more * More tests close to the underflow These are almost exactly halfway between 0 and the smallest representable float. * Implement error handling Mention the restrictions on the input, and that this implementation is experimental. * Add another caveat to the documentation * Make it compile with -DRYU_ONLY_64_BIT_OPS This mode was not defining mulShift. We just use the same implementation as if it's not set. * Use _BitScanReverse64 on Windows * Rename mulShift to mulShift{32,64} Since I moved the mulShift implementations to d2s_intrinsics, they conflict with the ones defined in f2s.c. This is only an issue when -DRYU_OPTIMIZE_SIZE is set, but I think it's better to disambiguate anyway. * Rename max to max32 to avoid name conflicts on MSVC * MSVC: Always use _BitScanReverse64 The HAS_64_BIT_INTRINSICS macro is false if RYU_ONLY_64_BIT_OPS is set, so using that is incorrect. Instead, only check for _MSC_VER. I can't seem to find a macro to check for existence of __builtin_clzll.
- Loading branch information
Showing
11 changed files
with
592 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.