Random double

qznc qznc at web.de
Tue Apr 23 23:37:50 PDT 2013


Tue, 23 Apr 2013 22:59:41 +0200: bearophile wrote

> qznc:
> 
>> I want to generate a random "double" value, excluding wierdos like NaN
>> and Infinity. However, std.random.uniform seems to be useless.
> 
> Can you explain why you need uniform doubles in their whole range? I
> think I have never had to generate them so far. Maybe for a unittest?

Good guess. :)

I want to port QuickCheck. The core problem is: Given a type T, generate a 
random value.

https://bitbucket.org/qznc/d-quickcheck/src/
eca58bb97b24cedd6128cdda77bbebeaf1689956/quickcheck.d?at=master

> Also note by their nature doubles are not equally spread across the line
> of Reals, so getting a truly uniform distribution is hard or impossible.

It also raises the question what uniform means in the context of floating 
point. Uniform over the numbers or uniform over the bit patterns?


More information about the Digitalmars-d-learn mailing list