add casts to make sure int-to-float error checking does what is intended