fix random generation on different platform. (problem with the range of qrand())