best_prefix for negative values #55

Closed
mbdm opened this Issue Jan 5, 2016 · 6 comments

Projects

None yet

2 participants

@mbdm
mbdm commented Jan 5, 2016

The result of best_practive is always in Bits for negative values. It might be interesting to work on the absolute values, to get a more human readable result. Thanks for your work.

@tbielawa
Owner
tbielawa commented Jan 5, 2016

Can you give me an example so i can understand better and reproduce what
you're describing please?

Thanks!
On Jan 5, 2016 2:09 PM, "mbdm" notifications@github.com wrote:

The result of best_practive is always in Bits for negative values It might
be interesting to work on the absolute values, to get a more human readable
result Thanks for your work


Reply to this email directly or view it on GitHub
#55.

@mbdm
mbdm commented Jan 5, 2016

Ok, here is an example.

>>> bitmath.best_prefix(10**8)
MiB(95.367431640625)
>>> bitmath.best_prefix(-10**8)
Bit(-800000000.0)

The following result might be more readable.

>>> bitmath.best_prefix(10**8)
MiB(95.367431640625)
>>> bitmath.best_prefix(-10**8)
MiB(-95.367431640625)
@tbielawa
Owner
tbielawa commented Jan 5, 2016

Oh wow! Yeah. That's a bug actually, the way i see it. I'll prioritize this
and get working on a fix.

Thank you for contributing to open source! :-)
On Jan 5, 2016 2:36 PM, "mbdm" notifications@github.com wrote:

Ok, here is an example.

bitmath.best_prefix(108)
MiB(95.367431640625)
bitmath.best_prefix(-10
8)
Bit(-800000000.0)

The following result might be more readable.

bitmath.best_prefix(108)
MiB(95.367431640625)
bitmath.best_prefix(-10
8)
MiB(-95.367431640625)


Reply to this email directly or view it on GitHub
#55 (comment).

@mbdm
mbdm commented Jan 5, 2016

Great. Thank you again. ;)

@tbielawa tbielawa added the bug label Jan 5, 2016
@tbielawa tbielawa self-assigned this Jan 5, 2016
@tbielawa
Owner
tbielawa commented Jan 7, 2016

@mbdm I've got a fix prepared and I'm going to push it up in a minute. I'll update this ticket again once I push an updated release to PyPi

@tbielawa tbielawa added a commit that closed this issue Jan 7, 2016
@tbielawa Fix best_prefix error when handling negative numbers
Now best_prefix will return the result using the best human-readable
prefix unit if given a negative number. Previously best_prefix would
return Bit types for ALL negative numbers instead of the best human
readable prefix unit.

* Closes #55
* Thanks @mbdm for the bug report
3d98a89
@tbielawa tbielawa closed this in 3d98a89 Jan 7, 2016
@mbdm
mbdm commented Jan 9, 2016

Thanks. New release on PyPi works fine. ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment