Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Random Functions
#7
boriel Wrote:RND was made float to be 100% compatible with Sinclair BASIC. In fact, much of it slowness comes from multiplying with another float number. E.g.
Code:
PRINT RND * 128
Not only generates an RND float number (0, 1), but also multiplies it by another float, 128. Thus much slower than the others.

Oh, absolutely. You did it completely right for the compiler - as I noted in the original post "going through float" is the slow part. My ugly hack here actually, rather than multiplies up numbers, even rolls a new random number until it finds one smaller than the specified limit. This, on average, is actually faster than a multiply, however. Unless there's a long string of fails.


boriel Wrote:I think it could be possible to put your routine in the library while taking the code fron rnd.asm (which already contains the random bit generator you use here). :?:

Yes - I think it might. The trick is to be able to call it and be sure it's in the final code - doesn't the compiler cut it out if rnd isn't used?
I suppose an initialise routine might do the trick.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)