ВходНаше всё Теги codebook 无线电组件 Поиск Опросы Закон Четверг
25 июля
122917 Топик полностью
alcosar (12.06.2008 21:01, просмотров: 258) ответил Alex B. на подскажите простой и быстрый генератор псевдослучайных чисел для 8-битников. Чтоб период побольше был... Конкретно интересует генерация 32-битных ПСЧ.
От автора csRTOS было в circuitcellar  // Extra bonus!!! The following psuedo-random number generator is of high statistical quality // and does not require any multiplies or divides, so it is fast on small micros. // An article describing it should appear in Circuit Cellar magazine soon after // the Atmel design contest is over. #define M 0x7FFFFFFF // 2^31-1, the modulus used by the psuedo-random // number generator prng(). I32 prng(I32 x) { // a good random number generator; call with 1 <= x <= M-1 x = (x >> 16) + ((x << 15) & M) - (x >> 21) - ((x << 10) & M); if (x < 0) x += M; return x; }