Binary sizes between neighboring prefixes

Programmers, kernel developers and embedded engineers divide memory into blocks that are powers of two. A page of memory is 4 KiB, a flash sector might be 64 KiB, and a buffer is sized in mebibytes. Moving from one prefix to the next is a factor of 1,024 and not 1,000, so a habit built on decimal prefixes leads to mistakes. This page multiplies mebibytes by 1,024 to give kibibytes. Because both units are binary, the answer is always a whole number when the input is whole, and the arithmetic stays easy to check. The page is most useful when a configuration file mixes MiB and KiB and you want one unit. It also helps when a vendor document gives a size in one prefix and the tool that consumes it expects the other, because a limit entered a thousand-fold too small or too large usually fails in a confusing way.

One step of 1,024

The IEC prefixes kibi, mebi, gibi and tebi stand for 2¹⁰, 2²⁰, 2³⁰ and 2⁴⁰, and the units are written KiB, MiB, GiB and TiB. A kibibyte is 1,024 bytes and a mebibyte is 1,024 kibibytes, which makes 1,048,576 bytes. The formula is KiB = MiB × 1,024. Since the factor is an integer power of two, the conversion is exact and works in both directions without rounding: a value in kibibytes divided by 1,024 gives mebibytes. The capital K in KiB distinguishes it from the SI kilo, which is written with a lowercase k and equals 1,000 in kB.

Ten mebibytes in kibibytes

The opening example enters 10 MiB and returns 10,240 KiB. The check is simple: 10 × 1,024 = 10,240. The same quantity in bytes is 10,485,760, which divided by 1,024 gives the same 10,240. A buffer of ten mebibytes therefore contains ten thousand two hundred forty blocks of one kibibyte. Because the result is an integer, there is no ambiguity in how many blocks you need. When the input has a fraction, such as 2.5 MiB, the result is 2,560 KiB, still an integer because 0.5 MiB is 512 KiB. Fractions of a mebibyte that are multiples of 1/1,024 always produce whole kibibytes.

Memory pages and allocation granularity

Operating systems manage memory in pages, commonly 4 KiB on x86 processors. One mebibyte holds 256 such pages, and 10 MiB holds 2,560. A program that requests 10 MiB receives 2,560 pages, and if you ask for slightly more, the system rounds up to the next whole page. Knowing the size in kibibytes helps you read tools that list mappings in KiB and compare them with a plan written in MiB. A quick division by 4 turns the kibibyte count into a page count, and the page converts the first step so you do not lose track of a factor of 1,024 along the way.

Reading kernel and tool output

Many tools print binary quantities under decimal-looking labels. The Linux file /proc/meminfo reports values with the label kB, yet each value is a count of 1,024-byte units, and the same habit appears in some process listings. If a field says 131,072 kB and you want the size in mebibytes, divide by 1,024 to get 128 MiB, which is the reverse of this page. Knowing the tool is binary under its label saves you from a conversion by 1,000 that would give 131 MB, a figure 2.3 percent below the true 134.2 MB of 128 MiB in decimal terms. When in doubt, check the documentation of the tool.

Embedded flash and sector sizes

Flash chips are divided into pages, sectors and blocks measured in kibibytes. A device with 128 MiB of flash holds 131,072 KiB, and a 0.75 MiB firmware image is 768 KiB. If the erase sector is 64 KiB, the image fills exactly 12 sectors, and a 2.5 MiB image of 2,560 KiB fills 40. The page supplies the kibibyte count, and you divide by the sector size to find the number of sectors to erase. Whole-sector rounding matters because partial sectors cannot be erased alone, so always round the sector count up and plan the layout of the image with that in mind. An image of 0.8 MiB, which is 819.2 KiB, needs 13 sectors of 64 KiB, with the last one only partly used.

From kibibytes back to mebibytes

Reverse the selection to move from a small unit to a larger one. A figure of 3,000 KiB is 2.9296875 MiB, found by dividing by 1,024. A figure of 4,096 KiB is exactly 4 MiB. The result has a finite decimal expansion because 1,024 is a power of two, so there are no repeating digits to round. Long tails such as .9296875 are normal for values that are not multiples of 1,024. For a report, round to two or three decimals unless the exact byte count matters. If it does, keep the figure in kibibytes or bytes and avoid the larger unit.

Why computers use 1,024

Memory chips are addressed with binary lines. With n address lines, a chip can hold 2ⁿ locations, so sizes naturally come in powers of two, and 2¹⁰ = 1,024 is close to a thousand. Early engineers borrowed kilo for 1,024 because it was convenient, and the habit stayed in memory sizes while storage makers adopted decimal units for drives. The IEC prefixes were created to remove the overlap. Using KiB and MiB in your documents makes the intended size clear without reading context. The page uses those names in its menus and reports the factor in the formula so that the definition is visible.

Mixing kB, KiB and MiB in one table

A configuration table that lists a 64 kB cache, a 512 KiB buffer and a 16 MiB heap is ambiguous about the first entry. If kB means 1,000 bytes, the cache is 62.5 KiB, which is 0.061 MiB. If it means 1,024 bytes, it is 64 KiB, which is 0.0625 MiB. Convert every row to one unit, and write the unit in the heading. With the kibibyte as the common unit the table is 62.5 or 64, 512 and 16,384. The page handles the last row, and the first row shows how large the gap between the two readings can be, 1.5 KiB for that entry alone. Across a long table of such entries, the difference adds up to a noticeable share of the total, which is why a unit column belongs in every configuration summary and every capacity review.