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.random.uniform of BigInt #9949

Open
dlangBugzillaToGithub opened this issue Jan 28, 2013 · 0 comments
Open

std.random.uniform of BigInt #9949

dlangBugzillaToGithub opened this issue Jan 28, 2013 · 0 comments

Comments

@dlangBugzillaToGithub
Copy link

bearophile_hugs reported this on 2013-01-28T16:27:18Z

Transfered from https://issues.dlang.org/show_bug.cgi?id=9419

Description

In some situations I'd like to generate a random BigInt:


import std.bigint: BigInt;
import std.random: uniform;
void main() {
    BigInt a = 0;
    BigInt b = BigInt(1) << 70;
    auto r = uniform(a, b);
}



Currently (DMD 2.062alpha) it gives:

...\dmd2\src\phobos\std\random.d(1106): Error: template std.random.uniform does not match any function template declaration. Candidates are:
...\dmd2\src\phobos\std\random.d(1104):        std.random.uniform(string boundaries = "[)", T1, T2)(T1 a, T2 b) if (!is(CommonType!(T1, T2) == void))
...\dmd2\src\phobos\std\random.d(1142):        std.random.uniform(string boundaries = "[)", T1, T2, UniformRandomNumberGenerator)(T1 a, T2 b, ref UniformRandomNumberGenerator urng) if (isFloatingPoint!(CommonType!(T1, T2)))
...\dmd2\src\phobos\std\random.d(1175):        std.random.uniform(string boundaries = "[)", T1, T2, UniformRandomNumberGenerator)(T1 a, T2 b, ref UniformRandomNumberGenerator urng) if (isIntegral!(CommonType!(T1, T2)) || isSomeChar!(CommonType!(T1, T2)))
...\dmd2\src\phobos\std\random.d(1255):        std.random.uniform(T, UniformRandomNumberGenerator)(ref UniformRandomNumberGenerator urng) if (isIntegral!(T) || isSomeChar!(T))
...\dmd2\src\phobos\std\random.d(1274):        std.random.uniform(T)() if (isIntegral!(T) || isSomeChar!(T))
...\dmd2\src\phobos\std\random.d(1106):        ... (1 more, -v to show) ...
...\dmd2\src\phobos\std\random.d(1104): Error: template std.random.uniform cannot deduce template function from argument types !("[)",BigInt,BigInt,MersenneTwisterEngine!(uint, 32, 624, 397, 31, 2567483615u, 11, 7, 2636928640u, 15, 4022730752u, 18))(BigInt,BigInt,MersenneTwisterEngine!(uint, 32, 624, 397, 31, 2567483615u, 11, 7, 2636928640u, 15, 4022730752u, 18))
...\dmd2\src\phobos\std\random.d(1106): Error: template instance uniform!("[)", BigInt, BigInt, MersenneTwisterEngine!(uint, 32, 624, 397, 31, 2567483615u, 11, 7, 2636928640u, 15, 4022730752u, 18)) errors instantiating template
test.d(6): Error: template instance std.random.uniform!("[)", BigInt, BigInt) error instantiating
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants