typecasting cost to integer to correct calculation errors