function rand returns an integer in range from 0 to RAND_MAX. to make a float from it, you have to divide it by some float (if you divide an int by another int the result will be int as well).
for example:

float r = rand()/(float)RAND_MAX;

this generates a random float value in range from 0 to 1.
(float) as well as static_cast<double> converts RAND_MAX to a float.