understanding the algorithm of rand() function from Visual C++
In C/C++,rand() and srand() are usually used by us when we want to get a random integer.But when I tried to rewrite it myself, I found it difficult to understand the algorithm.The function is very easily written only in a few lines,but the formula is misunderstanding,I want some help form programmers with good math,thanks:)

the main formula:
ptd->_holdrand = ptd->_holdrand * 214013L + 2531011L;

the original codes involved:

    void __cdecl srand (
            unsigned int seed
            )
    {
            _getptd()->_holdrand = (unsigned long)seed;
    }

    int __cdecl rand (
            void
            )
    {
            _ptiddata ptd = _getptd();
    
            return( ((ptd->_holdrand = ptd->_holdrand * 214013L
                + 2531011L) >> 16) & 0x7fff );
    }


understanding the algorithm of rand() function from Visual C++
===

In C/C++,rand() and srand() are usually used by us when we want to get a random integer.But when I tried to rewrite it myself, I found it difficult to understand the algorithm.The function is very easily written only in a few lines,but the formula is misunderstanding,I want some help form programmers with good math,thanks:)

the main formula:
ptd->_holdrand = ptd->_holdrand * 214013L + 2531011L;

the original codes involved:

    void __cdecl srand (
            unsigned int seed
            )
    {
            _getptd()->_holdrand = (unsigned long)seed;
    }

    int __cdecl rand (
            void
            )
    {
            _ptiddata ptd = _getptd();
    
            return( ((ptd->_holdrand = ptd->_holdrand * 214013L
                + 2531011L) >> 16) & 0x7fff );
    }

