- Cell Phones 1822
- Desktop 779
- Editors 411
- Education, Science & Engineering 1115
- Games 2029
- Internet 5086
- Multimedia & Graphics 977
- Office software 756
- PC 403
- Programming 1871
- 1C 126
- ActiveX 3
- Assembler 31
- C# 83
- C/С++ 294
- Data Bases 381
- Delphi/Pascal 496
- Disassemblers 6
- OpenGL/DirectX 5
- PHP 165
- Setup Software 22
- Visual Basic 25
- Others 234
- Security 777
- SEO 304
- Software for Pocket PC 194
- Utilities 1829
The random number generator without special functions
Refunds: 0
Uploaded: 29.12.2013
Content: genereator.doc 24,5 kB
Description
The need for random number generator occurs quite often. And we are not talking about the built-in functions such as Random (). We are talking about their own generator or an algorithm of such a generator. Only at first glance it is a trivial problem. Try to write yourself a generator and you will see that it is not easy. You are offered two programs (Pascal), generating random numbers, and special features are not used. The text of the program is very easy to understand and rewrite them in any programming language. The basis of the algorithm has recurrently expression, the treatment to which the parameters obtained in the previous step, and allows you to generate the next random number. The coefficients are chosen for two cycles - a length of 64, the other - 65536. Generated by integers of the range. The main advantage of the algorithm that kazhnyj random number range is generated exactly once. Try to find a built-in function. It is easy to rewrite the algorithms so that the numbers are not integers, and range for example from 0 to 1. In one of the programs is illustrated, but by comparing the program easily return to integers. The program is very short, work fast, differ only in a set of coefficients and variable types. The program algorithm can be adapted to other intervals for integers, but will have to tinker (requires knowledge of mathematics).
Additional information
You get a file in * .doc, which serves as the text of the two programs (the program - 12 lines with operators O and call).