Skip to content

Instantly share code, notes, and snippets.

@akkyie
Created May 22, 2017 11:50
Show Gist options
  • Save akkyie/ee2bd26b88f471e7723dd7de59a64087 to your computer and use it in GitHub Desktop.
Save akkyie/ee2bd26b88f471e7723dd7de59a64087 to your computer and use it in GitHub Desktop.
extension UInt {
func withZeroes(digits: UInt) -> String {
guard digits > 1 && Decimal(self) < pow(10, Int(digits - 1)) else {
return String(describing: self)
}
return "0" + self.withZeroes(digits: digits - 1)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment