bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gawk] Where is the default seed documented?


From: Aharon Robbins
Subject: Re: [bug-gawk] Where is the default seed documented?
Date: Wed, 20 Aug 2014 05:37:03 +0300
User-agent: Heirloom mailx 12.5 6/20/10

Hi.

Thanks for the report.

> Date: Tue, 19 Aug 2014 15:45:25 -0500
> From: Peng Yu <address@hidden>
> To: address@hidden
> Subject: [bug-gawk] Where is the default seed documented?
>
> Hi,
>
> It seems that a default seed is set to 1. But I don't see where this
> is documented. Could anybody show me where it is? Thanks.
>
> ~$ awk 'BEGIN{ print rand(); print srand(); }'
> 0.237788
> 1
> ~$ awk 'BEGIN{ print rand(); print srand(); }'
> 0.237788
> 1

You are correct that it's not documented. This appears to be an
oversight.  However, upon further reflection, it is good that this
is the case, since the initial seed varies among implementations
and is not specified by POSIX.  I have just added this text to
the manual in the description for srand:

        POSIX does not specify the initial seed; it differs among
        @command{awk} implementations.

Thanks,

Arnold



reply via email to

[Prev in Thread] Current Thread [Next in Thread]