在汇编语言伪随机数生成 [英] Pseudorandom generator in Assembly Language
本文介绍了在汇编语言伪随机数生成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要一个伪随机数生成器算法在课程指派一个汇编程序,我想preFER一个简单的算法。但是,我不能用一个外部库。
I need a pseudorandom number generator algorithm for a assembler program assigned in a course, and I would prefer a simple algorithm. However, I cannot use an external library.
什么是好的,简单的伪随机数生成器算法进行装配?
What is a good, simple pseudorandom number generator algorithm for assembly?
推荐答案
易一是只选择两个大素数的相对a和b,然后继续被乘以你的随机数和添加B。使用模运算符,以保持低的位作为随机数,并保持充分的价值为下一次迭代。
Easy one is to just choose two big relative primes a and b, then keep multiplying your random number by a and adding b. Use the modulo operator to keep the low bits as your random number and keep the full value for the next iteration.
这个算法是被称为线性同余发生器。
这篇关于在汇编语言伪随机数生成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文