Why don't you do a recursive function to print it out.
Say you got trillions of bytes which end at petabytes..
unitQuantity = 1024
unitTypes = ["b", "kb", "mb", "gb", "pb"]
def legibleByteFormat(unit, units, typeIndex):
if unit <= unitQuantity :
print(str(unit) + " " + " ".join(units))
else:
result = divmod(unit, unitQuantity)
units.insert(result[str(1])+ " "+ units[typeIndex])
typeIndex += 1
legibleByteFormat(result[0], units, typeIndex)
I just did the above on top of my head so it might have something I overlooked
or a typo.
On 12 Nov 2018, at 10:21 pm, Andy Borka <sonfire11@xxxxxxxxx> wrote:
Hi,
What is a safe value to use when converting between KB, MB, GB, and TB? For
example, a system utility puts out my amount of virtual memory in bytes. I
don't like the formatting and want to change it to something more
understandable. Here is some sample output from the utility.
total=16685772800
available=15263596544
percent=8.5
used=1003802624
free=14498136064
active=1033687040
inactive=829562880
buffers=53694464
cached=1130139648
shared=119803904
** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq