[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]
Re: Why am I not getting the results I expect...
"Venkatesha Murthy G." proclaimed:
> If we can safely assume that you're compiling this on a Linux machie,
> (you'd probably not have posted to this list otherwise, would you?)
> then the random () library function returns an integer (long int,
> actually; unless my manpages are dated; or yours). In which case you
> don't need to do any int-to-float-and-then-back-to-int conversions
> which are fraught with rounding related dangers which probably are
> giving you your headache.
>
> 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.
Thaths
--
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