let currentRatio = Double (rxCurrentTextField.text!)! / Double (txCurrentTextField.text!)! railRatioLabelField.text! = String(format: "%.2f", currentRatio)
Round up double to 2 decimal places
How do I round up currentRatio to two decimal places? let currentRatio = Double (rxCurrentTextField.text!)! / Double (txCurrentTextField.text!)! railRatioLabelField.text! = "\(currentRatio)"
stackoverflow.com
'Programming > Swift' 카테고리의 다른 글
Structures and Classes (0) | 2021.01.14 |
---|---|
Choosing Between Structures and Classes (0) | 2021.01.14 |
make a countdown with NSTimer? (0) | 2021.01.12 |
Immutable value X is never used consider replacing with '_' (0) | 2021.01.08 |
iOS: Tracking Visited Locations (0) | 2021.01.08 |