fix runtime crash
Cast double -> float fixing compile error in OSX