Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How many bytes is a gigabyte (GB)?

Tags:

c

When I convert between 1GB to byte using online tools, I get different answers. For instance, using Google Convertor: 1GB=1e+9 while in another converter I get 1GB= 1073741824. I suppose the unit is used in different fashion based on whether 1KB=1024B or 1KB=1000B (this is Google unit).

How can I know which unit my machine uses using a small C program or function? Does C have a macro for that? I want to do that as my program will possibly be run via various operating systems.

like image 671
Medo Avatar asked Jun 12 '17 07:06

Medo


People also ask

How many bytes is a GB?

Gigabyte (GB) A gigabyte is 1,073,741,824 (230) bytes. 1,024 megabytes, or 1,048,576 kilobytes. 894,784 pages of plain text (1,200 characters).

Is a gigabyte 1000 or 1024?

The term gigabyte has a standard definition of 10003 bytes, as well as a discouraged meaning of 10243 bytes. The latter binary usage originated as compromise technical jargon for byte multiples that needed to be expressed in a power of 2, but lacked a convenient name.

How many bytes is 1 GB and MB?

In other words, there are 1,048,576 bytes in 1 megabyte according to the binary system which computers use. So one gigabyte is equal to 1,073,741,824 bytes in base 2. This also means that there are 1,024 megabytes in one gigabyte in binary system.

How many bytes is a gigabyte quizlet?

A gigabyte is about one billion bytes.


2 Answers

The two tools are converting two different units. 1 GB = 10^9 bytes while 1 GiB = 2^30 bytes.

Try using google converter with GiB instead of GB and the mystery will be solved.

The following will help you understand the conversion a little better.

Factor  Name    Symbol  Origin  Derivation   Decimal
 2^10   kibi    Ki  kilobinary: (2^10)^1    kilo: (10^3)^1
 2^20   mebi    Mi  megabinary: (2^10)^2    mega: (10^3)^2
 2^30   gibi    Gi  gigabinary: (2^10)^3    giga: (10^3)^3
 2^40   tebi    Ti  terabinary: (2^10)^4    tera: (10^3)^4
 2^50   pebi    Pi  petabinary: (2^10)^5    peta: (10^3)^5
 2^60   exbi    Ei  exabinary:  (2^10)^6    exa:  (10^3)^6

Note that the new prefixes for binary multiples are not part of the International System of Units (SI). However, for ease of understanding and recall, they were derived from the SI prefixes for positive powers of ten. As shown in the table, the name of each new prefix is derived from the name of the corresponding SI prefix by retaining the first two letters of the SI prefix and adding the letters bi.

There's still a lot of confusion on the usage of GB and GiB in fact very often GB is used when GiB should or was intended to be. Think about the hard drives world: Your operating system assumes that 1 MB equals 1 048 576 bytes i.e. 1MiB. Drive manufacturers consider (correctly) 1 MB as equal to 1 000 000 bytes. Thus if the drive is advertised as 6.4 GB (6 400 000 000 bytes) the operating system sees it as approximately 6.1 GB 6 400 000 000/1 048 576 000 = ~6.1 GiB

Take a look at this for more info on prefixes for binary units and this on metric prefixes.

like image 103
Davide Spataro Avatar answered Oct 05 '22 04:10

Davide Spataro


This is just a confusion of units. There are actually two prefixes G for 10⁹ and Gi for 2³⁰. Bytes should usually be measured with the second, so the correct writing would be GiB.

like image 38
Jens Gustedt Avatar answered Oct 05 '22 06:10

Jens Gustedt