So I\'m trying to figure out how I can get my program to lose the .0 after an integer when I don\'t need the any decimal places.
@IBOutlet weak var numberOf
These answers really don't take into account the limitations of expressing Int.max and Int.min that Doubles have. Ints are 64 bit but Doubles only have 52 bits of precision in their mantissa.
A better answer is:
extension Double {
func toInt() -> Int? {
guard (self <= Double(Int.max).nextDown) && (self >= Double(Int.min).nextUp) else {
return nil
}
return Int(self)
}
}