Skip to content

brinsche/BitUnits

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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"

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages