A couple of years ago, I posted a message concerning the rand() function not giving very random results. (See
https://forum.pellesc.de/index.php?topic=7047.msg26739 and related post
https://forum.pellesc.de/index.php?topic=3193.msg12069) After doing a little digging, I realize now that what I was pointing out was not really a "bug" but rather an inherent weakness in the algorithm.
Just for fun, I decided to look at what the Pelles C implementation of rand() was actually doing. After examining the "show disassembly" code, I was able to write C code that produces the same results. The algorithm used is a linear congruential generator (LCG) with a "shuffle," akin to what is recommended in Numerical Recipes, 2nd Ed (1992).
Interestingly, in Numerical Recipes, 3rd Ed (2007), the authors basically state that times have changed and they now give the following warning: "Never use a generator principally based on a linear congruential generator (LCG)..." and "Never use a generator that warns against using its low-order bits as being completely random. That was good advice once, but it now indicates an obsolete algorithm (usually a LCG)." This last point about the low-order bits being non-random is what my original post was about.
The book shows three examples of modern algorithms which vary in speed and period, the fastest of which (Ranq1) is described as the "Recommended generator for everyday use." It's far better than the LCG methods and is very efficient: 3 XOR's, 3 shifts, and 1 multiply. Seems perfectly suited for rand().
Just a suggestion, but it seems to me that a more modern algorithm would be in order for Pelles C rand().