[riot-notifications] [RIOT] add mersene twister (#168)

René Kijewski notifications at github.com
Wed Aug 21 23:18:21 CEST 2013


> +static uint32_t mt[N]; /* the array for the state vector  */
> +static uint32_t mti = N + 1; /* mti==N+1 means mt[N] is not initialized */
> +
> +/**
> + * initializes mt[N] with a seed
> + */
> +void init_genrand(uint32_t s)
> +{
> +    mt[0] = s & 0xffffffffUL;
> +    for (mti = 1; mti < N; mti++) {
> +        mt[mti] = (1812433253UL * (mt[mti - 1] ^ (mt[mti - 1] >> 30)) + mti);
> +        /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
> +        /* In the previous versions, MSBs of the seed affect   */
> +        /* only MSBs of the array mt[].                        */
> +        /* 2002/01/09 modified by Makoto Matsumoto             */
> +        mt[mti] &= 0xffffffffUL;

The line does nothing. Even in a >32bit system you cannot fit a >32bit number in a uint32_t. Well, the compiler will scrape the line anyways …

---
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/168/files#r5909502
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20130821/8bf41c12/attachment.html>


More information about the notifications mailing list