Include <climits> for UINT_MAX + remove a cast, unsigned can NOT be greater UINT_MAX.