Issue 9419 - std.random.uniform of BigInt
Summary: std.random.uniform of BigInt
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P4 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-28 16:27 UTC by bearophile_hugs
Modified: 2024-12-01 16:16 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2013-01-28 16:27:18 UTC
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
Comment 1 dlangBugzillaToGithub 2024-12-01 16:16:15 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/phobos/issues/9949

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB