Skip to content

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
letvalue=UInt(4)letx=BitUnit.convert(value, from:.Megabit, to:.Kilobit)print(x)=>4000

Formatting

letx=BitUnit.format(1_177_171)!
print(x)=>"1.2 Mb"
letx=BitUnit.format(UInt64.max, targetUnitType:.BinaryByteUnit)print(x)=>"2048 PiB"

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages