aboutsummaryrefslogtreecommitdiff
path: root/lib/std/fmt/parse_float.zig
AgeCommit message (Collapse)Author
2025-06-08std.fmt.parseFloat: fix hex-float negative infMarc Tiehuis
Closes #24111.
2024-08-28std: update `std.builtin.Type` fields to follow naming conventionsmlugg
The compiler actually doesn't need any functional changes for this: Sema does reification based on the tag indices of `std.builtin.Type` already! So, no zig1.wasm update is necessary. This change is necessary to disallow name clashes between fields and decls on a type, which is a prerequisite of #9938.
2024-07-14std.fmt.parseFloat: add f80 formatFloat supportHarrison McCarty
2024-06-15std.float.parseFloat: fix large hex-float parsingMarc Tiehuis
There were two primary issues at play here: 1. The hex float prefix was not handled correctly when the stream was reset for the fallback parsing path, which occured when the mantissa was longer max mantissa digits. 2. The implied exponent was not adjusted for hex-floats in this branch. Additionally, some of the float parsing routines have been condensed, making use of comptime. closes #20275
2024-03-21std: remove one layer of redundant parse_float namespaceAndrew Kelley
there are still more, though. This provides a doctest for the `parseFloat` function.
2024-02-26Remove redundant test name prefixes now that test names are fully qualifiedRyan Liptak
Follow up to #19079, which made test names fully qualified. This fixes tests that now-redundant information in their test names. For example here's a fully qualified test name before the changes in this commit: "priority_queue.test.std.PriorityQueue: shrinkAndFree" and the same test's name after the changes in this commit: "priority_queue.test.shrinkAndFree"
2024-02-25fix large f128 values being incorrectly parsed as infMarc Tiehuis
Found while fuzzing. Previously 1.1897314953572317650857593266280070162E4932 was parsed as +inf, which caused issues for round-trip serialization of floats. Only f128 had issues, but have added other tests for all floating point large normals. The max_exponent for f128 was wrong, it is subtly different in the decimal code-path as it is based on where the decimal digit should go. This needs to be 2 greater than the max exponent (e.g. 308 or 4932) to work correctly (greater by 1, then we use a >= comparision). In addition, I've removed the redundant `optimize` constant which was only use for testing the slow path locally.
2023-11-03x86_64: fix std test failuresJacob Young
2023-10-27x86_64: fix c abi test failuresJacob Young
2023-10-25x86_64: pass more testsJacob Young
* 128-bit integer multiplication with overflow * more instruction encodings used by std inline asm * implement the `try_ptr` air instruction * follow correct stack frame abi * enable full panic handler * enable stack traces
2023-10-22Revert "Revert "Merge pull request #17637 from jacobly0/x86_64-test-std""Jacob Young
This reverts commit 6f0198cadbe29294f2bf3153a27beebd64377566.
2023-10-22Revert "Merge pull request #17637 from jacobly0/x86_64-test-std"Andrew Kelley
This reverts commit 0c99ba1eab63865592bb084feb271cd4e4b0357e, reversing changes made to 5f92b070bf284f1493b1b5d433dd3adde2f46727. This caused a CI failure when it landed in master branch due to a 128-bit `@byteSwap` in std.mem.
2023-10-21x86_64: fix bugs and disable erroring testsJacob Young
2023-07-25re-enable test "fmt.parseFloat nan and inf" after llvm fixJan Philipp Hafer
Closes #12027.
2023-06-24all: migrate code to new cast builtin syntaxmlugg
Most of this migration was performed automatically with `zig fmt`. There were a few exceptions which I had to manually fix: * `@alignCast` and `@addrSpaceCast` cannot be automatically rewritten * `@truncate`'s fixup is incorrect for vectors * Test cases are not formatted, and their error locations change
2023-03-25enable more float-parsing testsMarc Tiehuis
Since removing the stage1 backend we no longer have a disagreement here.
2023-03-16Fix #14901: parseFloat parsing `0x` successfullyEvin Yulo
2022-12-27Revert "aarch64: reenable tests that are no longer regressed"Andrew Kelley
This reverts commit 3370d58956ecc744a004dff47b0437473f0ef7da. This commit was done with an LLVM build that did not have assertions enabled. There are LLVM assertions being triggered due to this commit. Reopens #10627 Reopens #12013 Reopens #12027
2022-12-10aarch64: reenable tests that are no longer regressedr00ster91
Closes #12013 Closes #10627 Closes #12027
2022-12-06remove most conditional compilation based on stage1Andrew Kelley
There are still a few occurrences of "stage1" in the standard library and self-hosted compiler source, however, these instances need a bit more careful inspection to ensure no breakage.
2022-07-06std.fmt.parse_float: disable failing aarch64 test from LLVM 14Andrew Kelley
See #12027
2022-05-26add more corner case tests to float_parse (#11727)Andreas Reischuck
also drop some unused constants Co-authored-by: Andrew Kelley <andrew@ziglang.org>
2022-05-03add new float-parser based on eisel-lemire algorithmMarc Tiehuis
The previous float-parsing method was lacking in a lot of areas. This commit introduces a state-of-the art implementation that is both accurate and fast to std. Code is derived from working repo https://github.com/tiehuis/zig-parsefloat. This includes more test-cases and performance numbers that are present in this commit. * Accuracy The primary testing regime has been using test-data found at https://github.com/tiehuis/parse-number-fxx-test-data. This is a fork of upstream with support for f128 test-cases added. This data has been verified against other independent implementations and represents accurate round-to-even IEEE-754 floating point semantics. * Performance Compared to the existing parseFloat implementation there is ~5-10x performance improvement using the above corpus. (f128 parsing excluded in below measurements). ** Old $ time ./test_all_fxx_data 3520298/5296694 succeeded (1776396 fail) ________________________________________________________ Executed in 28.68 secs fish external usr time 28.48 secs 0.00 micros 28.48 secs sys time 0.08 secs 694.00 micros 0.08 secs ** This Implementation $ time ./test_all_fxx_data 5296693/5296694 succeeded (1 fail) ________________________________________________________ Executed in 4.54 secs fish external usr time 4.37 secs 515.00 micros 4.37 secs sys time 0.10 secs 171.00 micros 0.10 secs Further performance numbers can be seen using the https://github.com/tiehuis/simple_fastfloat_benchmark/ repository, which compares against some other well-known string-to-float conversion functions. A breakdown can be found here: https://github.com/tiehuis/zig-parsefloat/blob/0d9f020f1a37ca88bf889703b397c1c41779f090/PERFORMANCE.md#commit-b15406a0d2e18b50a4b62fceb5a6a3bb60ca5706 In summary, we are within 20% of the C++ reference implementation and have about ~600-700MB/s throughput on a Intel I5-6500 3.5Ghz. * F128 Support Finally, f128 is now completely supported with full accuracy. This does use a slower path which is possible to improve in future. * Behavioural Changes There are a few behavioural changes to note. - `parseHexFloat` is now redundant and these are now supported directly in `parseFloat`. - We implement round-to-even in all parsing routines. This is as specified by IEEE-754. Previous code used different rounding mechanisms (standard was round-to-zero, hex-parsing looked to use round-up) so there may be subtle differences. Closes #2207. Fixes #11169.
2021-08-24remove redundant license headers from zig standard libraryAndrew Kelley
We already have a LICENSE file that covers the Zig Standard Library. We no longer need to remind everyone that the license is MIT in every single file. Previously this was introduced to clarify the situation for a fork of Zig that made Zig's LICENSE file harder to find, and replaced it with their own license that required annual payments to their company. However that fork now appears to be dead. So there is no need to reinforce the copyright notice in every single file.
2021-08-20std.json: Add support for recursive objects to std.json.parse (#9307)Dmitry Matveyev
* Add support for recursive objects to std.json.parse * Remove previously defined error set * Try with function which returns an error set * Don't analyze already inferred types * Add comptime to inferred_type parameter * Make ParseInternalError to accept only a single argument * Add public `ParseError` for `parse` function * Use error.Foo syntax for errors instead of a named error set * Better formatting * Update to latest code changes
2021-06-21std, src, doc, test: remove unused variablesJacob G-W
2021-06-14add ast-check flag to zig fmt, fix found bugsVeikka Tuominen
2021-05-20Run `zig fmt` on src/ and lib/std/Isaac Freund
This replaces callconv(.Inline) with the more idiomatic inline keyword.
2021-05-08std: update usage of std.testingVeikka Tuominen
2021-03-05Reject bare +/- input when parsing floatscryptocode
2021-02-10Convert inline fn to callconv(.Inline) everywhereTadeo Kondrak
2020-12-31Year++Frank Denis
2020-11-05std: Implement more useful approxEq semanticsLemonBoy
Comparisons with absolute epsilons are usually useful when comparing numbers to zero, for non-zero numbers it's advised to switch to relative epsilons instead to obtain meaningful results (check [1] for more details). The new API introduces approxEqAbs and approxEqRel, where the former aliases and deprecated the old `approxEq`, allowing the user to pick the right tool for the job. The documentation is meant to guide the user in the choice of the correct alternative. [1] https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
2020-10-17Make std.meta.Int accept a signedness parameterJan Prudil
2020-09-05Merge pull request #6246 from Vexu/fieldVeikka Tuominen
Remove deprecated fields on `type`
2020-09-03std: Fix silent overflow in float parsing codeLemonBoy
A u64 can only hold 19 decimal digits, adjust the limit.
2020-09-03update uses of deprecated type field accessVexu
2020-08-20add license header to all std lib filesAndrew Kelley
add SPDX license identifier copyright ownership is zig contributors
2020-04-28std.meta.IntType -> std.meta.IntTadeo Kondrak
2020-03-29cleanup parse_float.zigxackus
2020-03-29fix overflow in parseFloatxackus
2020-02-25Merge remote-tracking branch 'origin/master' into llvm10Andrew Kelley
2020-02-24remove uses of `@ArgType` and `@IntType`Vexu
2020-02-07remove workarounds for Windows native CPU featuresAndrew Kelley
bug fixed in LLVM 10 closes #508
2020-01-21enable native CPU feature for windows; disable failing testsAndrew Kelley
See #508. These can be re-enabled when we upgrade to LLVM 10.
2020-01-07Use the correct calling convention for AEABI intrinsicsLemonBoy
2019-11-08update more of the std lib to use `@as`Andrew Kelley
2019-11-08update the codebase to use `@as`Andrew Kelley
2019-09-25mv std/ lib/Andrew Kelley
that's all this commit does. further commits will fix cli flags and such. see #2221