Fix undefined behaviour in float<->int conversion