Remarks: threadbare and thread
From Maze
(Difference between revisions)
| Line 117: | Line 117: | ||
In fact, as Neil Boyle explains, the C64 has two different ways of generating random numbers, and the machine ROM's random routine uses a different one depending on the sign of the value in the accumulator: | In fact, as Neil Boyle explains, the C64 has two different ways of generating random numbers, and the machine ROM's random routine uses a different one depending on the sign of the value in the accumulator: | ||
| − | <pre>The value held in the accumulator register when you call the routine determines what RND does. If the accumulator holds a negative byte value ($80-$FF), then the value in floating point accumulator 1 (FAC1) is used as the seed. If the accumulator holds zero, RND uses values from timer A and the time-of-day clock, just as in BASIC. If the accumulator value is positive ($00-$7F), then the seed value in locations $8B-$8F is used. [http://www.atarimagazines.com/compute/issue72/random_numbers.php]</pre> | + | <blockquote>The value held in the accumulator register when you call the routine determines what RND does. If the accumulator holds a negative byte value ($80-$FF), then the value in floating point accumulator 1 (FAC1) is used as the seed. If the accumulator holds zero, RND uses values from timer A and the time-of-day clock, just as in BASIC. If the accumulator value is positive ($00-$7F), then the seed value in locations $8B-$8F is used. [http://www.atarimagazines.com/compute/issue72/random_numbers.php]</blockquote> |
In BASIC, this would mean the difference between executing RND(1) and RND(-1). The first method generates the same sequence of random numbers every time you turn on the computer, no matter what positive value is passed to it. The second method uses the value passed as the seed. As Boyle explains, there's a third method, too: if the value passed to RND() is zero, then the machine uses its internal clock as the random number seed. | In BASIC, this would mean the difference between executing RND(1) and RND(-1). The first method generates the same sequence of random numbers every time you turn on the computer, no matter what positive value is passed to it. The second method uses the value passed as the seed. As Boyle explains, there's a third method, too: if the value passed to RND() is zero, then the machine uses its internal clock as the random number seed. | ||
