From: Charles Comstock Date: 2005-07-08T21:27:31+09:00 Subject: Possible Bug in Documentation or implementation of srand According to documentation srand of 0 is supposed to reset srand to some random value from the clock and whatnot. Unfortuneatly this only actually occurs if you call srand with no argument. See example below: irb(main):001:0> srand 0 => 0 irb(main):002:0> rand => 0.548813503927325 irb(main):003:0> rand => 0.715189366372419 irb(main):004:0> srand 0 => 0 irb(main):005:0> rand => 0.548813503927325 irb(main):006:0> rand => 0.715189366372419 irb(main):007:0> srand => 0 irb(main):008:0> rand => 0.0934072350449292 irb(main):009:0> Here is the apparently documentation that seems to be mistaken from my interpretation ----------------------------------------------------------- Kernel#srand srand(number=0) => old_seed ------------------------------------------------------------------------ Seeds the pseudorandom number generator to the value of _number_.+to_i.abs+. If _number_ is omitted or zero, seeds the generator using a combination of the time, the process id, and a sequence number. (This is also the behavior if +Kernel::rand+ is called without previously calling +srand+, but without the sequence.) By setting the seed to a known value, scripts can be made deterministic during testing. The previous seed value is returned. Also see +Kernel::rand+. It's possible that I may misinterpreting something in this description but it seems like the line "If _number is omitted or zero, seeds the generator" is not happening as exhibited in my above example. Can anyone shed any light on this behavior? Is the code incorrect or is the documentation incorrect? Charles Comstock