std.random

Kramer Kramer_member at pathlink.com
Tue Apr 11 11:58:36 PDT 2006


In article <pjctg3-8g7.ln1 at birke.kuehne.cn>, Thomas Kuehne says...
>
>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: SHA1
>
>Charles schrieb am 2006-04-11:
>> Charles wrote:
>>> How do i get a number in the range -0.5 to 0.5 ?
>
>const float RAND_MAX = uint.max;
>float sum = 0.0;
>for(size_t i = 1; i < 101; i++){
>    float x = (rand() / RAND_MAX) - 0.5;
>    sum += x;
>    writefln("round:%s\t%s\t(%s)", i, x, sum / i);
>}
>
>Thomas
>
>
>-----BEGIN PGP SIGNATURE-----
>
>iD8DBQFEPAMv3w+/yD4P9tIRAvPEAJ42zaytStz2jn5BhwkB3YAM3D4B0ACgiDDk
>8wfG8fdPa8ijUaDOVbdHW3g=
>=xxyV
>-----END PGP SIGNATURE-----

Forgive me for asking such a naive (I feel I should know this already) question
and taking this off-topic, but what is the type size_t?  I've seen it used (and
also ptrdiff_t I believe), but I don't know what they're for or how to use them?

-Kramer





More information about the Digitalmars-d-learn mailing list