Two binary units, one power of two

This pair is unusual among storage conversions because both units belong to the same binary family. A KiB is 1,024 bytes and a GiB is 1,073,741,824 bytes, so the ratio is 2^20, or 1,048,576. There is no decimal prefix and no rounding. Programmers meet this ratio often, because the smallest unit of many memory allocators, buffer settings and page-size parameters is expressed in KiB while the total comes from a GiB figure. The page gives the multiplication in one step so that you do not have to chain GiB to MiB and MiB to KiB, which is where a slip of 1,000 versus 1,024 tends to enter. Everything on this page stays within base 2.

The factor 1,048,576

The number 1,048,576 is 1,024 times 1,024. The IEC binary prefixes, published in IEC 80000-13 and listed in NIST SP 811, define kibi as 2^10 and gibi as 2^30, so a gibibyte holds 2^20 kibibytes. Many programmers remember this value as one million forty-eight thousand five hundred seventy-six, and it appears in the classic count of bytes in a mebibyte as well. Here it is a plain integer multiplier, so any whole number of gibibytes gives a whole number of kibibytes. A fractional input gives a whole number whenever it is a multiple of 2^-20 GiB, which is the case for every size that is a whole number of KiB.

The default of ten GiB

Ten GiB equals 10,485,760 KiB. This is 10 × 1,048,576, and it is a handy figure because many Linux tools and database settings quote sizes in KiB. A single GiB is 1,048,576 KiB, a quarter of a GiB is 262,144 KiB and three GiB is 3,145,728 KiB. A value of 1.5 GiB gives 1,572,864 KiB, and 8 GiB gives 8,388,608 KiB, the figure most often seen for an 8 GiB machine. Because the output is an integer for sizes that are multiples of 1 KiB, you can use it directly in a configuration file without worrying about decimals. If a tool wants the answer in bytes instead, multiply the kibibyte result by 1,024.

Kernel and database settings

Operating systems report many memory counters in KiB. The kernel memory statistics on Linux list values labeled kB that are in fact multiples of 1,024 bytes, so a machine with 8 GiB of memory shows a total close to 8,388,608 in those counters, before the kernel reserves its share. Database settings are similar: a shared buffer parameter may accept a size in KiB, and a request for 2 GiB becomes 2,097,152 KiB. The labeling is inconsistent across tools, which is why this converter uses the IEC symbol KiB for the binary unit and keeps kB for the decimal one, so there is no ambiguity about which is meant.

Reverse conversion and spot checks

To go from KiB to GiB, divide by 1,048,576. A readout of 2,097,152 KiB is 2 GiB, and 524,288 KiB is 0.5 GiB. A fast check without a calculator is to remember that 1,048,576 KiB is 1 GiB, so a number just over a million KiB is about one gibibyte. A value of 3,000,000 KiB is about 2.861 GiB, and 500,000 KiB is about 0.477 GiB, which is a little under half a gibibyte. When a reading such as 16,777,216 KiB shows up, it is a power of two, 2^24, and so exactly 16 GiB. Powers of two in the output are a signal that the hardware or the allocator is working in binary units.

Precision is not an issue here

Since the factor is an integer, the multiplication does not lose digits for sizes you would ever type. The only precision question is on the input side. If you enter 0.1 GiB, the result is 104,857.6 KiB, a fraction of a kibibyte, which no file system can allocate as such. Round to the allocation unit the target system uses, often a whole KiB or a page of 4 KiB. A tenth of a gibibyte is therefore about 104,858 KiB, and rounding up is the safer choice when the figure is a minimum size for a buffer or a partition. Going the other way, a value such as 100,000 KiB is 0.095367431640625 GiB, a long but finite decimal, and trimming it to 0.0954 is fine for a report.

Mistakes specific to KiB and kB

The most common error is reading a KiB result as if it were decimal kB. A value of 10,485,760 KiB is 10,737,418.24 kB, about 2.4 percent larger than the KiB number, because each kibibyte is 1,024 bytes and a kilobyte is 1,000. A second error is dropping the i. Software that prints KB or kb may mean KiB, kB or even kilobits, and only the vendor documentation settles it. A third error is confusing mebibytes and kibibytes when doing the arithmetic by hand, which is a factor of 1,024 off. This page removes that step by using the single factor between the two units that you choose.

What the number does and does not describe

The converted value is an amount of data. It says nothing about speed, compression or how much room a file system needs once metadata and block rounding are included. A 10 GiB disk image can need slightly more or less actual space depending on whether it is thin-provisioned, and a RAM figure in KiB from the kernel excludes memory the firmware reserved earlier. Use the conversion for planning and for typing values into settings, and read actual usage from the system that stores the data. Two sizes that match after conversion can still behave differently on disk. The definitions used here match NIST SP 811 and IEC 80000-13.

Tuning a buffer from a GiB budget

A practical case is splitting a memory budget into equal buffers. Say a service is given 6 GiB and you want eight caches of equal size. Six GiB is 6,291,456 KiB, and dividing by eight gives 786,432 KiB per cache, a whole number that is also a multiple of 4 KiB, so it lines up with the page size. If the budget were 6.5 GiB, the total would be 6,815,744 KiB and each of eight caches would get 851,968 KiB. Working in KiB keeps every figure an integer, which is easier to review than a fractional GiB such as 0.8125. Write the final values in the unit the configuration file expects and keep the GiB figure in a comment so the intent survives later edits.