improved unsigned int to long conversion