Mail Archives: djgpp/1997/04/08/15:04:25
In article <3349B612 DOT 68C AT ucsu DOT Colorado DOT edu>, William Heymann <heymann AT ucsu DOT Colorado DOT edu> writes:
>
|>random() & 9 only returns 0, 1, 8, and 9.
That's all it can return. "&" means bit-wise and. 9 only has the 8 bit
and the 1 bit on, and the only numbers you can make with those bits
are 0,1 8 and 9. If you want numbers in a range, you need to do
a modulo divide: random() % 10 will give you numbers between 0 and 9,
inclusive.
------------------------------------------------------------------------------
Kevin Ashley K DOT Ashley AT Ulcc DOT ac DOT uk
Development Manager http://www.ulcc.ac.uk/staff/Kevin+Ashley
University of London Computer Centre. ...ukc!ncdlab!K.Ashley
This is not a signature
- Raw text -