Bug 3025 – uniform(float,float) pops first, uniform(int,int) pops last

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2009-05-25T07:59:00Z
Last change time
2015-06-09T01:27:58Z
Assigned to
andrei
Creator
lio+bugzilla

Comments

Comment #0 by lio+bugzilla — 2009-05-25T07:59:32Z
I noticed in random.d, uniform template, that popFront is called in different locations for integral compared to floating point types: for integral types you .front first and .popFront afterwards, but for floating point types you start with .popFront and then check .front. This has a peculiar effect: for example, if you do uniform(0.0,100.0) followed by uniform(0,100) there's a big chance that the integral part of the first random number is equal to the second random number. import std.stdio, std.random; void main() { writeln(uniform(0.0,100.0)); writeln(uniform(0,100)); } The location of .popFront should be standardized, either before or after any .front.
Comment #1 by andrei — 2009-08-27T22:23:09Z
I always call popFront at the end now.