Use cast to eliminate signedness warnings