Below is my code.. I am doing 5 + 2 and I would like the output to be 7 but I am getting 7.0. Can someone please help me and tell me why
var runningNumber:Double = 5
var currentValue:Double = 2
var total:Double = Double(runningNumber + currentValue)
print(total)
4
Answers
I got it working but changing the code to this
you could just do this:
Consider using
.formatted()
to format the floating point number properly for you:Int
s instead ofDouble
sInt
when printingNumberFormatter