[Issue 6023] std.random.uniform and std.bigint.BigInt compilation error

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jun 21 02:51:50 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=6023



--- Comment #6 from Don <clugdbug at yahoo.com.au> 2012-06-21 02:54:00 PDT ---
(In reply to comment #5)
> (In reply to comment #4)
> 
> > Because BigInt type is not integral.
> > 
> >   import std.traits;
> >   pragma(msg, isIntegral!BigInt);  // pritns false
> 
> Maybe we'll need to add to std.traits a new trait that's true for all integral
> values, BigInts too.

It's a bit difficult. If BigInt used the same algorithm for random number
generation that built-in ints use, the performance would be horrible.

For an n-byte number, you'd have O(2n) memory allocations on average, with an
unbounded worst case, instead of the single allocation you'd have with a
dedicated algorithm.

And generating a string of 1 million random bits is the sort of thing that
somebody is likely to do.

Supporting it with terrible performance isn't any better than not supporting it
at all.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list