beware of unsigned int, when calculating 0 - 1.