How can i check if a number is decimal or not using swift?
With Objective-C:
if (number == (int) number) { //decimal } else { //not decimal }
extension FloatingPoint { var isInteger: Bool { rounded() == self } }
(You'll also need to use the return keyword if you're not using Swift 5.1 or later.)
return
1.4m articles
1.4m replys
5 comments
57.0k users