I now have the David Reinagels 16bit Random Number algorithm - thanks. I am looking to generate a random number in the range 0-1, then 0-2, then 0-3,...... upto 0-49. I figured the easiest way might be for range 0-n if n<=15 sum first n+1 bits in rand (16 bit number) if 16<=n<=27 take first 4 bits<0-3> of rand giving a number 0-15 and then add sum of remaining n-15 bits starting from bit <4> if 28<=n<=30 take bits <0-4> giving a number 0-31 and subtract sum of 31-n bits starting from bit <5> if 31<=n<=42 take bits <0-4> and add sum of n-31 bits from <5> For 43<=n<=50 I will probably have to generate 2 random nos and add (eg for 0-50 generate one in range 0-15 and one 0-35 and add). I'd be OK from 53-73 as I can use <0-5> and then add/substract sum of remaining unused bits) as above. This seems intrinsically faster than doing multiply/divides to generate a number in range. I don't believe it unbalances randomness. Anyone got any better ideas (particularly for 43-50)? Is this a well know technique? BTW My earlier problems with MPLAB were indeed dumb user! Brian. Brian Jones Java Technology Centre IBM Hursley