Created
July 17, 2021 13:44
-
-
Save deathlezz/2024f5ff967198384c5a0d79b41467b3 to your computer and use it in GitHub Desktop.
Rounding numbers in Swift 5.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Rounding numbers | |
// | |
import Foundation | |
let number = 15.4444444445 | |
let round = String(format: "%.2f", number) // 2f stands for two decimal places | |
print(round) // 15.44 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment