On changing rand(3) to random(3) in awk(1)
Chenguang Li
horus.li at gmail.com
Thu Aug 28 14:34:01 UTC 2014
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
Peter Pentchev <roam at ringlet.net> wrote:
>> On Thu, Aug 28, 2014 at 10:17:55PM +0800, Chenguang Li wrote:
>>
>> ... ...
>> [omitted]
>>
>> Wait a minute, isn't LONG_MAX architecture-dependent? It's 9223372036854775807
>> on my 64-bit FreeBSD box. The range of generated random numbers is explicitly
>> documented. So I am afraid I should hard-code 2^32-1 in the file.
>
> ...
>
> I missed the *second* sentence of the random(3) manual page, didn't I.
> Specifically looked it over, looked for limits, checked the bottom for
> various sections that may document constants and stuff... and missed the
> second sentence.
That's totally fine. :)
> Of course you're right, it's documented as 2^32-1. Though now I wonder
> whether stdlib.h shouldn't provide some kind of RANDOM_MAX constant for
> this purpose, instead of programs having to do their own hardcoding.
It would be nice to have it as a constant, as RAND_MAX for rand(3).
Chenguang Li
-----BEGIN PGP SIGNATURE-----
iQIcBAEBCgAGBQJT/z3NAAoJELG4cS+11lRhIPoQANoQD6vze5QCK8yN4EWf8B3S
7VzAk6xsY7F2xFjIh/OVGihg7GE83ClwDkEWsbujM8NygqRX3DfMEk4wODWIX3Z/
yjChFFOH+DOHhFXMKFL8p4uEZzUKNZEHRBK0dXlUbCxQsd1YQStnxFGtZhef+90I
9DpQKyKfMzF7eQxHeCMh2s5JNUO8k0jIEPEZWxamjziwIkSPoVqUB50XjtzaIkt6
uU/LuqNukGUbBZSBFbH/2BLRB0Zgv72ncLvBqF8RyIOTL6D80C9ZFw8Snxk198Mj
YPmgX+amW1ZydmERzDX3H8jHZ16ejcyufa05rOvlxUF4B8elqeoYamB43dKnmIfp
0JO+96g+1V0pzr1byrMxOlHCTrpObA1sI4egnkccgDr23OuchO/ifWAHsSMk8FUB
pE65PxIMNzpdn9coWbfdWAhR2+pw9Pnb4zrzOPF47SkVO8vzyLIPr2ncH492FMh7
shyPOVTTck9Ows3OINomT5EyRH0WKyX8MEVwRZwfF0V8hb9MG3taoqGi9MiQN34g
ObrX5E8ciZhEsz0j3UUXgYHFkM+A0+vMMcaqOWXlfAmpMyNa8QOq1WhlvfG9TvS6
KQUfxSWWgpZGNAW4AjNKnoqvM83hZBiCBZA+BypnaEFa2meVRcYDYmBVjB80JoDR
vT1m6di0RFT48Zg4Zdlo
=AqYi
-----END PGP SIGNATURE-----
More information about the freebsd-hackers
mailing list