Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
All floats I've tried now print correctly.
See #375 (comment) for the first commit. The further changes are
For the last bullet, maybe we want to wait for an upstream confirmation and patch.
Tests
The tests I made are here (see the
usage
file at the bottom). All the tests I've run have passed. In particular the f32 tests are intended to show by exhaustion that we're correct for all f32s.f32 I iterate over all positive u32s, bitCasting them to f32s, skipping the NaNs and Infs, and printing the rest to stdout in zig. This is piped into a C program where I scanf with
%f
and check if the nth one I get bitcasts back to n. This should exhaustively test all positive f32s.If you want to check all f32s, just change the 0x80000000s to 0xffffffffs in both files. I didn't just because it takes about 2 hours to run already.
rand This generates some random numbers with xoroshiro128+, bitcasts to f64, prints them, pipes them into C, scanfs them with
%lf
and checks if they're the same. The more times you run it, the greater your confidence should be that we're correct :)