Last active
June 2, 2018 12:52
-
-
Save JanGorman/00e41916f3aa8fa2bf1a3c95f743b7c5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // 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