in reply to Re^2: Slightly Srandom JAPH
in thread Slightly Srandom JAPH

...I would expect srand JAPH to be the same thing as srand "JAPH", which should be the same thing as srand 0.

Since v5.14, srand returns the random number seed as well as setting it. So perl -e "print srand JAPH;" shows how JAPH is interpreted as a seed. On the perls I have to hand (all Strawberry Perl, except for v5.16.3, which is Citrus Perl), srand JAPH is the same as srand "JAPH", but in version 5.18 it is no longer the same as srand 0:

perlsrand JAPH
5.14.40 but true
5.16.00 but true
5.16.30 but true
5.18.018446744073709551615
5.18.118446744073709551615

I haven’t found the reason for this. But the resulting warning was introduced in v5.18. From the “New Warnings” section of perl5180delta#New-Diagnostics:

"Integer overflow in srand" srand() now warns when passed a value that doesn't fit in a UV (since +the value will be truncated rather than overflowing) [perl #40605].

See also perldiag#Integer-overflow-in-srand.

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Replies are listed 'Best First'.
Re^4: Slightly Srandom JAPH
by Tux (Canon) on Dec 30, 2013 at 08:32 UTC

    To complete that table: all perl versions 5.003_07 .. 5.13.3 will print 1, 5.13.4 .. 5.17.1 will print 0 but true, and 5.17.2 .. 5.19.6 will print 18446744073709551615 with the "Integer overflow in srand" warning.


    Enjoy, Have FUN! H.Merijn