storaged-project / libbytesize

A tiny library providing a C "class" for working with arbitrary big sizes in bytes
GNU Lesser General Public License v2.1
21 stars 21 forks source link

Calculator #56

Closed vpodzime closed 5 years ago

vojtechtrefny commented 5 years ago

Ideas for further development:

vojtechtrefny commented 5 years ago

Found few "bugs" (mostly just not returning nice error messages):

Modulo with integer traceback:

$ python3 bs_calc.py "4 B % 2"
Traceback (most recent call last):
...
AttributeError: 'int' object has no attribute '_c_size'

Zero division traceback:

$ python3 bs_calc.py "4 B / 0"
Traceback (most recent call last):
...
bytesize.bytesize.ZeroDivisionError: Division by zero

Parsing exponents fails:

$ python3 bs_calc.py "1e5 MiB"
Error while parsing expression: Failed to parse size spec: 1e5 MiB

but it works with negative powers:

$ python3 bs_calc.py "1e-5 MiB"
10 B
0.01 KiB
vpodzime commented 5 years ago

Support for sectors. (I can use */512, but I'm too lazy.)

Sector size depends on the device.

vpodzime commented 5 years ago

This needs some more work on adding the man page.

vpodzime commented 5 years ago

This needs some more work on adding the man page.

DONE.

vojtechtrefny commented 5 years ago

Jenkins, test this please.