lua-users home
lua-l archive

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


On Sat, Mar 22, 2014 at 8:24 AM, Coroutines <coroutines@gmail.com> wrote:
> On Sat, Mar 22, 2014 at 8:21 AM, Luiz Henrique de Figueiredo
> <lhf@tecgraf.puc-rio.br> wrote:
>>> Among many programming circles, rand() is considered harmful.
>>
>> The Lua manual warns about this. Note that it says that the quality
>> of math.random() cannot be guaranteed, not that it must be bad.
>>
>> I seemed to recall that recent glibc had a much better rand() but
>> I can't find the source of that quote and the glibc sources do not show
>> a better RNG. (My recollection was that rand() actually was drand48() or
>> random() but the sources do not show it.)
>>
>
> Would it not be safe to assume rand() is a wrapper around something
> better within the C library?  The risk is using rand() on older
> systems.

On Mac OS X the man page reads:
...
DESCRIPTION
     These interfaces are obsoleted by arc4random(3).
...

I'd bet my bottom-dollar rand is calling arc4random() internally.  I
bet you my next paycheck rand() as an interface is deprecated to keep
people from using it on older systems with poorer implementations :-)