Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Not so much a bug, as slow!
#19
einar Wrote:
britlion Wrote:Random number generators that are faster, and, sans rom probably smaller, here:

<!-- m --><a class="postlink" href="http://www.boriel.com/wiki/en/index.php/ZX_BASIC:RandomStream.bas">http://www.boriel.com/wiki/en/index.php ... Stream.bas</a><!-- m -->

Thanks for the link! This is exactly the functionality I was looking for, except it can't skip the part that counts number of bits. So there would be still some advantage in incorporating this logic into the compiler...
It's what Britlion said: the compiler uses RND as a float for compatibility reasons with Sinclair Basic. RND is a float between 0 and 1.

Some BASICs implements RAND(a, b) as a RANDOM integer generator, but I think it's not a good idea to extend the BASIC language anymore (like C). C is a tiny language with a huge library set which makes it very portable. On the contrary BASIC is very system-dependent, and some library functions are embedded in the language (RND, SIN, COS).

This is one of the problems I'm tackling right now: If SIN, COS, RND were libraries and not functions, development and porting to other systems would be easier (and this wouldn't change the syntax). Thus RANDOM function created by Britlion is a good example of a function that should go into a Library Wink and not embedded in the language.

BTW RND is a function with 0 params. Try RND() instead. I discovered this in 2008! Confusedhock:
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)