fix coverity issue 1258907 Division or modulo by float zero
replace insecure std::rand by C++11's random number generation

fixes coverity issue 1248916 Don't call