Skip to content

Instantly share code, notes, and snippets.

@cmcbride
Created May 16, 2011 01:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmcbride/973751 to your computer and use it in GitHub Desktop.
Save cmcbride/973751 to your computer and use it in GitHub Desktop.
ocaml: check if float is an int
(* ways to check if float is an integer *)
let is_int v =
v = (snd (modf v))
;;
let better_is_int v =
let c = classify_float (fst (modf v)) in
c == FP_zero
;;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment