I would like to display a Double
with no decimals in Swift.
The location.speed
comes from Map Kit.
This is what I have tried:
let kmt = location.speed * (18/5)
let theKmt = Double(round(10*kmt)/10)
statusLabel.text = "km/t\(theKmt)"
You're probably looking for this:
let d: Double = 1.12345
statusLabel.text = String(format: "%.0f", d)
let d: Double = 1.23456
let doub: Double = 1.23456
print(String(format: "%.0f", d))
print(Int(doub))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With