Skip to content

Instantly share code, notes, and snippets.

@deathlezz
Created July 17, 2021 13:44
Show Gist options
  • Save deathlezz/2024f5ff967198384c5a0d79b41467b3 to your computer and use it in GitHub Desktop.
Save deathlezz/2024f5ff967198384c5a0d79b41467b3 to your computer and use it in GitHub Desktop.
Rounding numbers in Swift 5.
//
// 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