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
2.1m questions
2.1m answers
60 comments
57.0k users