11.07.2015 Views

Here - 1000 BiT

Here - 1000 BiT

Here - 1000 BiT

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

uINSTRUCTOR NOTES 13 RANDOM NUMBERS AND THE INT FUNCTION uThis lesson introduces two functions: RND and INT. These are very important in gamesand also handy in making interesting displays like kaleidoscopes.The RND function produces psuedo-random decimal numbers larger than 0 and smallerthan 1. Such numbers are directly usable as probabilities, but integers over some range ^Jsuch as 1 to 6 for a die, or 1 to 13 for a suit of cards are often more directly usable.Your student may be shaky in decimal arithmetic, but all that is required here is ,multiplication of the random number by an integer, and perhaps also addition to aninteger. The computer does the multiplication, of course, so only a rough idea of the ^jdesired result is necessary.After extending the random number to a larger range than 0 to 1, conversion to aninteger is desired. The INT function does this by simply truncating the number, "throwing ^away the decimal part." (For negative numbers the situation is a little more complicated, *>and that rare case is not treated here.)The concept of "rounding off' may be familiar to your student. INT will round off anumber if you first add 0.5 to it.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!