How am I supposed to cast a float to an integer in OCaml?
I know how to get a float from an int, but there doesn’t seem to be an easy way to get an int from a float.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I assume you want a nearby
int(this rounds towards zero, same as C does).If you want the IEEE representation, see
Int64.bits_of_float.