Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
BitUnits.xcodeproj
Sources/BitUnits
Tests
.gitignore
.travis.yml
LICENSE
Package.swift
README.md

README.md

BitUnits Build Status

Utility library to convert and format SI and IEC bit and byte units.

Samples

Converting

//Ints return an optional, because we only support values >= 0.
//In case you can guarantee this, it’s safe to force unwrap the return value

let value = UInt(4)
let x = BitUnit.convert(value, from: .Megabit, to: .Kilobit)
print(x)
=> 4000

Formatting

let x = BitUnit.format(1_177_171)!
print(x)
=> "1.2 Mb"
let x = BitUnit.format(UInt64.max, targetUnitType: .BinaryByteUnit)
print(x)
=> "2048 PiB"
You can’t perform that action at this time.