You can convert it to decimal in software, but then you have to divide by 32. You must utilise the full range of the random number generated by the rand function, otherwise sometimes no LEDs will be on.
Here is a lightweight solution without multiplications and divisions. You can do a simple set of if/elseif statements. You might need to change this to compile under HITECH C. The idea is to decimate the number into ranges.
unsigned char var; //declare
var = rand (); //initialise by generating a random number 0...255.
if ((var>=0) && (var<=31)) light_led(1);
elseif ((var>=32) && (var<=63)) light_led(2);
elseif ((var>=64) && (var<=95)) light_led(3);
.....
elseif ((var>=223) && (var<=255)) light_led(
;
Even if you get the logic a bit wrong, only 1 led will light up because of the elseif statement.
Simples!
EDIT: Sean, the method in your last post above will not work, it only samples regions inside the dynamic range of the random variable. Most of the times the bitwise operation it will return 0. For example, if the random number is 8 in decimal i.e. 0x00001000, then 0x00001000 & 0x00000111 = 0x00000000 i.e. 0.