Using Swift 3.
I am finding a lot of strange solutions online for checking if a Decimal object is a whole number. Everything feels far more complicated then it needs to be.
Here is my solution:
extension Decimal {
var isWholeNumber: Bool {
return self.exponent == 1
}
}
In my tests this works. My question is am I missing something obvious?