added cast to unsigned to compile with gcc3.2 (sparc)