http://llvm.org/bugs/show_bug.cgi?id=18767
Bug ID: 18767
Summary: uniform_real_distribution produces variates in its
range _inclusive_ rather than exclusive.
Product: libc++
Version: unspecified
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: All Bugs
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Classification: Unclassified
The following program should complete successfully.
#include <cassert>
#include <random>
#include <cmath>
int main() {
double range[] = {1.0, std::nextafter(1.0, 2.0)};
std::uniform_real_distribution<double> dist(range[0], range[1]);
std::default_random_engine eng;
for (int i=0; i<10; ++i) {
double v = dist(eng);
assert(range[0] <= v && v < range[1]);
}
}
Using libc++ it instead produces an assertion failure. Other implementations
(vc++ and libstdc++) exhibit the same behavior.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs