You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the latest version of bitmath, im trying to convert a bit value into the best bit prefix. as seen below the output is always converted to bytes, I would like to keep the value in bits so best for this would be mebibits not mebibytes
>>> b = 130130.75
>>> m = Kib(b)
>>> m
Kib(130130.75)
>>> m.best_prefix()
MiB(15.885101318359375)
edited by tbielawa to use correct prefix units in the written form, replaced 'mega' with 'mebi' at end of description
The text was updated successfully, but these errors were encountered:
@ajwillo Thanks for posting your question. You gave me something interesting to think about.
I have to admit, when I first saw this issue roll in I wasn't quite sure what to make of it, that's not your fault, that's mine. I thought to myself, "well, best_prefix is technically working as advertised".
But then I thought about this issue again today and I realized that you've identified a very legitimate use-case that absolutely has value. I completely missed this in the initial design of best_prefix. Thank you for filing this RFE.
To maintain current expected functionality I can't change the default behavior of best_prefix, but what I think I can do instead is add an optional keyword argument to the method and function such that the user can specify that they would like to preserve the original base unit. That way you could ensure you get back a bit or byte based unit back, depending on the input.
Using the latest version of bitmath, im trying to convert a bit value into the best bit prefix. as seen below the output is always converted to bytes, I would like to keep the value in bits so best for this would be mebibits not mebibytes
edited by tbielawa to use correct prefix units in the written form, replaced 'mega' with 'mebi' at end of description
The text was updated successfully, but these errors were encountered: