Created
March 4, 2018 14:13
-
-
Save mwrites/c973c1aae9f65684732458abe695e7a0 to your computer and use it in GitHub Desktop.
Check if Float is Int
This file contains hidden or 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
extension FloatingPoint { | |
var isInt: Bool { | |
#if swift(>=4.0) | |
return self.truncatingRemainder(dividingBy: 1) == 0 | |
#else | |
return self % 1 == 0 | |
#endif | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment