Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std::rand: wrappers for floats from [0,1] and (0,1). #10542

Merged
merged 1 commit into from
Nov 19, 2013

Conversation

huonw
Copy link
Member

@huonw huonw commented Nov 18, 2013

Provide Closed01 and Open01 that generate directly from the
closed/open intervals from 0 to 1, in contrast to the plain impls for
f32 and f64 which generate the half-open [0,1).

Fixes #7755.

fn floating_point_edge_cases() {
// the test for exact equality is correct here.
assert!(ConstantRng(0xffff_ffff).gen::<f32>() != 1.0)
assert!(ConstantRng(0xffff_ffff_ffff_ffff).gen::<f64>() != 1.0)
}

fn rand_open() {
// this is unlikely to catch an incorrect implementation that
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

testing rngs: isn't it wonderful?

Provide `Closed01` and `Open01` that generate directly from the
closed/open intervals from 0 to 1, in contrast to the plain impls for
f32 and f64 which generate the half-open [0,1).

Fixes rust-lang#7755.
bors added a commit that referenced this pull request Nov 19, 2013
Provide `Closed01` and `Open01` that generate directly from the
closed/open intervals from 0 to 1, in contrast to the plain impls for
f32 and f64 which generate the half-open [0,1).

Fixes #7755.
@bors bors closed this Nov 19, 2013
@bors bors merged commit e6fb622 into rust-lang:master Nov 19, 2013
@huonw huonw deleted the open01 branch November 19, 2013 09:35
flip1995 pushed a commit to flip1995/rust that referenced this pull request Apr 6, 2023
…iraffate

Fix allow attribute, items from macros in `items_after_statements`

Fixes rust-lang#10540

changelog: [`items_after_statements`]: Fixes `#[allow(clippy::items_after_statements)]` when applied to an item, and ignores items after statements from different macro contexts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle infinities in rand::distributions::zero_case
4 participants