rust-fuzz / rust-fuzz/arbitrary
Best way to generate float values in range
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 880
- Forks
- 93
- PR merge metrics
- No merged PRs in 30d
Description
Hi folks, in https://github.com/technocreatives/dbc-codegen/issues/12 we're generating implementations of Arbitrary for structs where we know some values have to be in a specific range. For ints, this is not a problem as we just use Unstructured::int_in_range, but I'm unsure how to proceed for floats. (We currently just go with always setting the float field to the lower bound.)
My initial idea was to keep generating floats until we get one in ourr range, but that seems awfully slow. Is there a good strategy for generating floats that are in a specific range? Anything I should look up? All I can find assumes an existing random number library is in place… which I'm hesitant to add just for this.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked issue and the existing Unstructured::int_in_range approach to understand how bounded integers are generated. Review the seven-comment discussion for an agreed strategy and constraints around adding a random-number dependency. Done means the project has a decided, tested way to generate float values within requested bounds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- testing-qa
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100