This function uses floating point math again, can we get rid of this?