Alonso Alonso -4 years ago 71
C Question

How to know the size a gigabyte?

When I convert between 1GB to byte using online tools, I get different answers. For instance, using Google Convertor:

while in another converter I get
1GB= 1073741824
. I suppose the unit is used in different fashion based on whether
(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.

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download