Skip to content

Repository files navigation

BinaryIntegerFormatting

XcodeSwiftGitHub tag (latest SemVer)GitHub

What

BinaryIntegerFormatting is a Swift Package Manager package for iOS/tvOS (10.0 and above), watchOS (4.0 and above), and macOS (10.14 and above), under Swift 5.0 and above, defining some useful functions for formatting integers.

Ordinarily, one should use NumberFormatter to format numbers but I've found use cases where this package has been more useful, especially when localisation isn't an issue.

publicextensionBinaryInteger{vardigitCount:Intfunc digits<Base:BinaryInteger>(base:Base)->[Self]var binaryDigits:[Self]var decimalDigits:[Self]func digitString<Base:BinaryInteger>(
base:Base,
separator c:Character,
every n:Int)-> String func binaryString(
separator c:Character=".", every n: Int = 0, fullBithWidth: Bool = false ) -> String  func decimalString( separator c: Character = ",",  every n: Int = 3 ) -> String  func formatted( width: Int, leftPadding: Character = "", rightPadding: Character = "", alignment: String.Alignment = .right ) -> String  var description: String { return decimalString() }}

Dependencies

BinaryIntegerFormatting depends on two other Swift packages of mine, StringFormatting and CollectionSplitting.

Installation

BinaryIntegerFormatting is provided only as a Swift Package Manager package, because I'm moving away from CocoaPods and Carthage, and can be easily installed directly from Xcode.

License

BinaryIntegerFormatting is available under the MIT license. See the LICENSE file for more info.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages