[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]
Re: Why am I not getting the results I expect...
Sharat Chandra proclaimed:
> > > So if you have random () returning long on your machine, this should
> > > suffice
> > >
> > > ((int) (random ()) % 24) + 1
> > Thanks Venkatest. I figured this out by accident yesterday. Now I know
> > the reason why it worked.
> A small piece of information:
> The lower order bits of a random number generated by the "remainder" method
> are supposed to be less random than the higher order bits. Saw this in a
> book "Numerical Recipies in C".
That is what rand()'s man page said too. That was why I was doing the
whole int -> float -> int casting. random() seems to a different beast
One more thing I did not mention was that I was using that snippet of code
in a module for xscreensaver. random() behaves different when used inside
a xscreensaver module. It is porbably because of some of the utility
functions I am linking against.
Marge: Okay, but you've accomplished a lot! You've made me very happy.
Homer: Oh, yeah, they'll put me on a stamp for that!
Sudhakar C13n http://www.aunet.org/thaths/ Lead Indentured Slave