[Qt-interest] Best Random Number Generator in Qt

Denis Akhmetzyanov dakhmetzyanov at smartlabs.tv
Thu Apr 15 14:15:30 CEST 2010


You could use:

int mpainter::getRandomNumber(int max)
{
   return qrand() % max;
}


2010/4/15 Aaron Lewis <aaron.lewis1989 at gmail.com>

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi,
>        For example , i'd like to get a integer range from 0 to max , i can
> use
> such a function:
>
> int mpainter::getRandomNumber(int max)
> {
>    return double(qrand()) / RAND_MAX * max;
> }
>
> But i don't think this is a good way to generate it , i always got a
> number two.
>
> Is there any good method to generate random number in range ?
>
> Appreciate any of your help ;-)
>
> - --
> Best Regards,
> Aaron Lewis - PGP: 0x4A6D32A0
> FingerPrint EA63 26B2 6C52 72EA A4A5 EB6B BDFE 35B0 4A6D 32A0
> irc: A4r0n on freenode
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.14 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAkvHAQ8ACgkQvf41sEptMqDEIgCfZYyF2NIR3sEr+/ldA5vSWVxt
> 84EAnibCo5O54pDnw5W3EY0E5hPWTXL5
> =SrC/
> -----END PGP SIGNATURE-----
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>



-- 
Best regards,
Denis Akhmetzyanov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100415/ab6553cc/attachment.html 


More information about the Qt-interest-old mailing list