lua-users home
lua-l archive

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


Roberto and Sergio,


the fix math.randomseed(os.time()) did work.

I misused the clock() function, expecting the ticks from the operating system start, not the application.

As a result, as Roberto points, I'm most probably passing a value of 0 or close to 0, useless as you said.

The funny thing is that I don't even use anything random, just that I use skeletons from app to app, so code was there for no use.

Much fast support, do you sleep anytime?

Ciao


----------------------------------
Antonio de Curtis

Sent with ProtonMail Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Friday, December 11, 2020 6:55 PM, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:

> > On Fri, Dec 11, 2020 at 2:33 PM Luiz Henrique de Figueiredo
> > lhf@tecgraf.puc-rio.br wrote:
> >
> > > > Except that math.randomseed(os.clock()) is not working. It does not like that clock as parameter.
> > >
> > > What error message do you get?
> >
> > I guess Antonio should use os.time instead of os.clock.
>
> Note that, even in Lua 5.3, math.randomseed(os.clock()) does not raise
> an error, but it probably does not do what you want. If you call that in
> the beginning of the program, 'os.clock()' will return a small fraction
> that will always be rounded to zero, so that math.random produces the
> same numbers at every run.
>
> -- Roberto