Created
May 16, 2011 01:13
-
-
Save cmcbride/973751 to your computer and use it in GitHub Desktop.
ocaml: check if float is an int
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* 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