bitmath is Pythonic! https://github.com/tbielawa/bitmath More information: https://blog.lnx.cx/?p=521
This file contains 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
>>> from bitmath import * | |
>>> GiB(42) * 3 | |
GiB(126.0) | |
>>> Bit(9) + Byte(3) | |
Bit(33.0) | |
>>> exbi = EiB(0.6) | |
>>> mega = MB(700) | |
>>> exbi / mega | |
988218432.5201545 | |
>>> exbi - mega | |
EiB(0.599999999393) | |
>>> mega + exbi | |
MB(6.91752903464e+11) | |
>>> print "Over 9000 Gibibits: %s" % Gib(9001) | |
Over 9000 Gibibits: 9001.0Gib | |
>>> thirty_megabytes = MB(30) | |
>>> thirty_megabytes.bytes | |
30000000 | |
>>> thirty_mb_as_kb = kB(bytes=30000000) | |
>>> print thirty_megabytes, thirty_mb_as_kb | |
30.0MB 30000.0kB | |
>>> thirty_megabytes == thirty_mb_as_kb | |
True | |
>>> TiB(1) < GB(1000) | |
False | |
>>> TiB(1) < GB(10000) | |
True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment