[LLVMbugs] [Bug 18767] New: uniform_real_distribution produces variates in its range _inclusive_ rather than exclusive.
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri Feb 7 09:08:05 PST 2014
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: hhinnant at apple.com
Reporter: seth.cantrell at gmail.com
CC: llvmbugs at cs.uiuc.edu
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140207/b55e4a90/attachment.html>
More information about the llvm-bugs
mailing list