Location of popFront

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon May 25 06:56:14 PDT 2009


Lionello Lunesu wrote:
> Andrei,
> 
> 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));
> }
> 
> I don't think this warrants a bug report, but I do think the location of 
> .popFront should be standardized, either before or after any .front.
> 
> Just sayin'.
> 
> L.

Definitely warrants a bug report. I'm busy today but I might find time 
for it tomorrow.

Andrei



More information about the Digitalmars-d mailing list