The 'binary' library (ofek/binary) provides a straightforward and reliable way to convert between binary (IEC) and decimal (SI) units. It is currently at version 1.0.2, with releases driven by bug fixes and new features, maintaining an active development status.
pip install binaryVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic unit conversion, calculating actual storage from advertised decimal units, and generating human-readable unit representations.
Review any code explicitly converting units to bytes and verify that floor division provides the expected results. Adjust logic if rounding behavior has changed unexpectedly.
Always explicitly specify `BinaryUnits` or `DecimalUnits` to avoid ambiguity. Refer to IEC 80000-13 and SI standards for clarity if unsure.
For explicit control, always provide both the `unit` and `to` arguments. If relying on automatic conversion, be mindful of the default behavior for binary vs. SI units.
Install the library using pip: `pip install binary`
Ensure the input string contains only '0' and '1' when converting from binary: `binary.convert('1010', from_unit=binary.BINARY, to_unit=binary.DECIMAL)`Provide the correct data type for the specified `from_unit`. If `from_unit` is `binary.BINARY`, the `value` must be a string; if `from_unit` is `binary.DECIMAL`, the `value` must be an integer: `binary.convert('1010', from_unit=binary.BINARY, to_unit=binary.DECIMAL)` or `binary.convert(10, from_unit=binary.DECIMAL, to_unit=binary.BINARY)`Consult the library's documentation to ensure you are using the correct function names and attributes, e.g., `binary.convert` for unit conversion.
No dependency data recorded yet.