C truncates when casting from float to int, so add a 0.5 offset before casting