Why are you thinking about unsigned integers anyway? rand() is limited to the precision of a double (53 bits) and beyond that there will be integers it never generates. rand() is really only suitable for cheap throwaway random numbers anyway. Check perldoc -f rand for alternatives.