bitmath icon indicating copy to clipboard operation
bitmath copied to clipboard

Why not represent bit count as integer?

Open florisla opened this issue 3 years ago • 2 comments

Hi,

I find this a bit unintuitive:

>>> bitmath.KiB(1/3).to_Bit()
Bit(2730.6666666666665)

I would expect this to throw an exception (I did not specify an integer count of bytes).

There seems to be a precision of 12 decimals, but a bit is non-divisible. So 0.666 bit is not a quantity of bits which can exist.

What is the purpose of using floating point sizes in bitmath, when you could represent bit count as an integer everywhere?

florisla avatar Oct 15 '21 11:10 florisla

I think the best solution will be to math.floor() results from division.

tbielawa avatar Feb 15 '23 22:02 tbielawa

Things being a float by default is more of a core design choice I made forever ago that I need to look at again a lot more closely.

tbielawa avatar Feb 15 '23 22:02 tbielawa