Function that converts a number to his version with Binary prefix @input value (an integer) @example: >>> add_binary_prefix(65536) '64.0 kilo'
(value: float)
| 101 | |
| 102 | |
| 103 | def add_binary_prefix(value: float) -> str: |
| 104 | """ |
| 105 | Function that converts a number to his version with Binary prefix |
| 106 | @input value (an integer) |
| 107 | @example: |
| 108 | >>> add_binary_prefix(65536) |
| 109 | '64.0 kilo' |
| 110 | """ |
| 111 | for prefix in BinaryUnit: |
| 112 | numerical_part = value / (2**prefix.value) |
| 113 | if numerical_part > 1: |
| 114 | return f"{numerical_part!s} {prefix.name}" |
| 115 | return str(value) |
| 116 | |
| 117 | |
| 118 | if __name__ == "__main__": |
nothing calls this directly
no outgoing calls
no test coverage detected