Yeah. you made mistake in calculation.
random = (rand()%32767+1)/32767;

It takes 32767 values integer and this (rand()%32767+1) value as float. so it returns 0.000000

Change the calculation...