cast lhs to rhs type to avoid signed/unsigned comparisons warnings