1. Bytes Question

Hello All,

x=dir(myfile)
x[D_SIZE] would be the file size in bytes.
So would file size in Kbytes would be x[D_SIZE]/1000
or x[D_SIZE]/1024 ? What about Mbtyes?

Don Cole

new topic     » topic index » view message » categorize

2. Re: Bytes Question

don cole wrote:
> 
> Hello All,
> 
> x=dir(myfile)
> x[D_SIZE] would be the file size in bytes.
> So would file size in Kbytes would be x[D_SIZE]/1000
> or x[D_SIZE]/1024 ? What about Mbtyes?
> 
> Don Cole

A Kbyte is defined as 1024 bytes while a MByte is 1024 * 1024 =1048576 bytes.
x[D_SIZE]/1024 would be correct. 

Larry Miller

new topic     » goto parent     » topic index » view message » categorize

3. Re: Bytes Question

don cole wrote:
> 
> Hello All,
> 
> x=dir(myfile)
> x[D_SIZE] would be the file size in bytes.
> So would file size in Kbytes would be x[D_SIZE]/1000
> or x[D_SIZE]/1024 ? What about Mbtyes?
> 
> Don Cole


Beware, x[1][D_SIZE] would be the file size of myfile in bytes.

However one MB is 1024k in a binary system; if we have 256k, 512k etc.
1000 should have nothing to do with the true size.

antonio

new topic     » goto parent     » topic index » view message » categorize

4. Re: Bytes Question

don cole wrote:

> x=dir(myfile)
> x[D_SIZE] would be the file size in bytes.
> So would file size in Kbytes would be x[D_SIZE]/1000
> or x[D_SIZE]/1024 ? What about Mbtyes?

Good question. smile

x[1][D_SIZE]/1000 = file size in kilobit (kbit)
x[1][D_SIZE]/1024 = file size in kibibit (Kibit)

see <http://physics.nist.gov/cuu/Units/binary.html>

Regards,
   Juergen

-- 
Please excuse my flawed English. My native language is Euphoria.

new topic     » goto parent     » topic index » view message » categorize

5. Re: Bytes Question

Correction of my first post in this thread
(of course it must be "byte" here, not "bit"):

don cole wrote:

> x=dir(myfile)
> x[D_SIZE] would be the file size in bytes.
> So would file size in Kbytes would be x[D_SIZE]/1000
> or x[D_SIZE]/1024 ? What about Mbtyes?

Good question. smile

x[1][D_SIZE]/1000 = file size in kilobyte (kbyte)
x[1][D_SIZE]/1024 = file size in kibibyte (Kibyte)

see <http://physics.nist.gov/cuu/Units/binary.html>

Regards,
   Juergen

-- 
Please excuse my flawed English. My native language is Euphoria.

new topic     » goto parent     » topic index » view message » categorize

6. Re: Bytes Question

> x=dir(myfile)
> x[D_SIZE] would be the file size in bytes.
> So would file size in Kbytes would be x[D_SIZE]/1000
> or x[D_SIZE]/1024 ? What about Mbtyes?

KiloByte: 1024 Bytes
MegaByte: 1024 KiloBytes (1,048,576 Bytes)
GigaByte: 1024 MegaBytes (1,073,741,824 Bytes)
TeraByte: 1024 GigaBytes (1,099,511,627,776 Bytes)

For each step (KB, MB, GB, TB) divide by 1024.

~Greg

new topic     » goto parent     » topic index » view message » categorize

7. Re: Bytes Question

>> x=dir(myfile)
>> x[D_SIZE] would be the file size in bytes.
>> So would file size in Kbytes would be x[D_SIZE]/1000
>> or x[D_SIZE]/1024 ? What about Mbtyes?

>KiloByte: 1024 Bytes
>MegaByte: 1024 KiloBytes (1,048,576 Bytes)
>GigaByte: 1024 MegaBytes (1,073,741,824 Bytes)
>TeraByte: 1024 GigaBytes (1,099,511,627,776 Bytes)

>For each step (KB, MB, GB, TB) divide by 1024.

>~Greg

It may or may not be relevant depending on what you are upto/why you want to
know,
but some manufacturers, especially those of hard disk drive (HDD) abuse the
system.
You can frequently find HDD capacities in GB
that are measured as 10^9 bytes instead of 2^30

Jordan

new topic     » goto parent     » topic index » view message » categorize

8. Re: Bytes Question

This link is informative.

 http://en.wikipedia.org/wiki/Megabyte

Summary:
Because of inconsistencies in the use of SI-derived prefixes such as kilo- and
mega-, the exact number can be any one of the following:

1,048,576 bytes (1,0242, 220): This definition is used for nearly all
discussions of computer memory (as computer addresses are naturally powers of
two, making it efficient to manufacture memory in power-of-two capacities) and
file storage. As of 2005, most software uses this definition to express storage
capacity (e.g. file size).

1,000,000 bytes (1,0002, 106): This is the definition recommended by SI and IEC.
It is used primarily in networking contexts and most storage media, particularly
hard drives and DVDs. This definition of 'mega-' as a SI prefix is consistent
with the other SI prefixes, and with many other uses of the prefix in computing,
such as CPU clock speeds or measures of performance.

1,024,000 bytes (1,024×1,000): This definition occurs rarely. It was used in a
small number of storage contexts, most notably the "1.44 MB" (actually 1,474,560
bytes), and the "3.5-inch" (actually 90 mm) high-density floppy diskette.

Several attempts to resolve these inconsistencies have been proposed, most
notably the standard created by the IEC to redefine 1,048,576 bytes as a
"mebibyte". This standard has been adopted by several organizations, such as the
NIST and IEEE.


-- 
Derek Parnell
Melbourne, Australia
Skype name: derek.j.parnell

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu