I think it's better to use floats and then cast to int before outputting values.
Remove outcommented debug line.