Re: Converting bytes
- Posted by jimcbrown (admin) Jul 06, 2016
- 2191 views
doncCcole said...
What's the formula to convert them to Gigs, Megs, or Ks, whichever is appropriate?
if amt>GIG then --GIG handling routine elsif amt>MEG then --MEG handling routine elsif amt>K then --K handling routine end if
This is as far as I can get.
I don't know where to start .
Like so:
constant GIG=power(2, 30), MEG=power(2, 20), KIL=power(2, 10) atom temp if amt>GIG then --GIG handling routine temp = amt / GIG printf(1, "%g GIG\n", {temp}) elsif amt>MEG then --MEG handling routine temp = amt / MEG printf(1, "%g MEG\n", {temp}) elsif amt>KIL then --K handling routine temp = amt / KIL printf(1, "%g KIL\n", {temp}) else temp = amt printf(1, "%g BYT\n", {temp}) end if
doncCcole said...
I am confused by the following:
GIG,MEG,K to represent Binary Values
and gig,meg,k to represent Decimal Values
If you are not sure then you probably want the binary version (1024 etc) and not the decimal version.