LINUX.ORG.RU

История изменений

Исправление saahriktu, (текущая версия) :

Примеры, кстати, были в прежних версиях манов. Потом многие из них зачем-то поубирали, заменив в некоторых местах другими. Например, я помню ман rand() с вот таким примером:

       In Numerical Recipes in C: The Art of Scientific Computing (William H.  Press,  Brian  P.  Flannery,  Saul  A.
       Teukolsky, William T. Vetterling; New York: Cambridge University Press, 1992 (2nd ed., p. 277)), the following
       comments are made:
              "If you want to generate a random integer between 1 and 10, you should always do it by using high-order
              bits, as in

                     j=1+(int) (10.0*rand()/(RAND_MAX+1.0));

              and never by anything resembling

                     j=1+(rand() % 10);

              (which uses lower-order bits)."
Так что, иногда полезно и старые версии документации почитать.

Исходная версия saahriktu, :

Примеры, кстати, были в прежних версиях манов. Потом многие из них зачем-то поубирали. Например, я помню ман rand() с вот таким примером:

       In Numerical Recipes in C: The Art of Scientific Computing (William H.  Press,  Brian  P.  Flannery,  Saul  A.
       Teukolsky, William T. Vetterling; New York: Cambridge University Press, 1992 (2nd ed., p. 277)), the following
       comments are made:
              "If you want to generate a random integer between 1 and 10, you should always do it by using high-order
              bits, as in

                     j=1+(int) (10.0*rand()/(RAND_MAX+1.0));

              and never by anything resembling

                     j=1+(rand() % 10);

              (which uses lower-order bits)."
Так что, иногда полезно и старые версии документации почитать.