Skip to content

Instantly share code, notes, and snippets.

@JanGorman
Last active June 2, 2018 12:52
Show Gist options
  • Select an option

  • Save JanGorman/00e41916f3aa8fa2bf1a3c95f743b7c5 to your computer and use it in GitHub Desktop.

Select an option

Save JanGorman/00e41916f3aa8fa2bf1a3c95f743b7c5 to your computer and use it in GitHub Desktop.
// Float comparison
infix operator ==~ : ComparisonPrecedence
func ==~<T> (lhs: T, rhs: T) -> Bool where T: FloatingPoint {
return lhs == rhs || lhs.nextDown == rhs || lhs.nextUp == rhs
}
// 0 padded numbers
let formatter = NumberFormatter()
formatter.minimumIntegerDigits = 20
formatter.string(for: 30) // 00000000000000000030
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment