Convert MiB to B

MiB
1048576B

1 MiB = 1048576 B

One mebibyte is exactly 1,048,576 bytes, so converting MiB to bytes is a multiplication by 1,024 twice rather than by a million. This is the direction you need when a config value, a buffer length or a test fixture has to be an exact integer that something else will enforce.

  • Where it runs In your browser. The number you type is never part of a request.
  • Exact by definition 1 MiB is exactly 1048576 B — a definition, not a rounded factor.
  • Answers as you type No button, no wait. The worked answer is already on the page before any script runs.

Mebibyte to Byte in practice

  • 703 MiB is 737100000 B

    — a data CD, which is 700 MB on the label.

  • 8 MiB is 8389000 B

    — a chunk of memory a program might allocate.

  • 4.768 MiB is 5000000 B

    — a photograph from a phone.

  • 0.0009766 MiB is 1024 B

    — a kibibyte, which is where the confusion starts.

Mebibyte to Byte at a glance

Every figure here is computed from the same definition the calculator uses, so the table cannot drift away from the answer above it.
MiBB
11048576
22097152
55242880
1010485760
5052428800
100104857600
500524288000
10001048576000

Mebibyte and Byte

A mebibyte is 1,024 kibibytes, or 1,048,576 bytes. Linux tools and memory sizes generally mean this even when they print "MB".

A byte is eight bits, though that was not always fixed — early machines used six, seven or nine. The eight-bit byte won because it holds one character of text and divides neatly in half.

A mebibyte is exactly 1,048,576 bytes

Going this way is a multiplication, and by a whole number: one mebibyte is 1,048,576 bytes, exactly, and 1,048,576 is the definition rather than a measurement that came close.

That makes it one of the few conversions worth doing in your head, and it makes the answer checkable: divide back and you must land on the number you started with, exactly, with no remainder to explain away.

MiB is the binary one

One MiB is 1,024 of the unit below it; one MB is 1,000. On this page that is the difference between 1048576 B and 1000000 B — 4.9 % — and the gap grows at every step up the scale, which is why it is a rounding error on a photograph and a visible chunk of a hard disk.

This is the whole of the missing-storage mystery, and on this page it is worth 4.9 %. A drive sold in MB holds exactly what the label says; Windows divides by 1,024 instead of 1,000, keeps the decimal name, and reports 1000000 B where the box said 1048576. macOS has counted these in the decimal units since 10.6, which is why the same drive can look two sizes on two machines — nothing is missing and nobody is rounding, the same bytes have two names.

The value that has to be exact, not readable

Most size conversions exist so a person can picture a quantity. This one usually exists so a machine can enforce one. An upload limit, a heap size, a buffer allocation, a chunk boundary in a multipart transfer — each of these is an integer that something compares against, and a value rounded to look tidy is a value that fails at the edge rather than in the middle where it would be noticed.

So the useful figure here is 1,048,576 and its multiples, not an approximation. Ten MiB is 10,485,760 bytes; 64 MiB is 67,108,864; 512 MiB is 536,870,912. Every one of those is a number somebody has typed into a configuration file this week, and every one of them is a digit away from a value that is quietly 4.86 per cent different.

The suffixes that mean MiB without writing MiB

A surprising amount of software takes a size with a letter on the end and treats that letter as 1,024-based. The nginx k and m suffixes are binary. The JVM heap flags -Xms512m and -Xmx2g are binary. PHP’s upload_max_filesize = 8M is binary. None of these write the i, and none of them say so in the line you are editing.

GNU dd is the instructive case because it accepts both conventions and distinguishes them by length: bs=1M is 1,048,576 bytes and bs=1MB is 1,000,000. That is a defensible design and a reliable trap, because the two spellings look like typing variants of one another. When copying a block size between scripts, copy the suffix exactly or replace it with the byte count.

Mi and M in the same field: the Kubernetes case

Kubernetes resource quantities accept both scales explicitly, so memory: 512Mi is 536,870,912 bytes and memory: 512M is 512,000,000. Both are valid, both pass schema validation, and the difference is a single letter in a file that will be applied without anyone reading it again. On a memory limit, the smaller value is the one that gets a container terminated under load that the larger one survives.

The gap widens up the scale, which is where it does real damage. At the mega step it is 4.86 per cent; at giga it is 7.37 per cent, so 4Gi and 4G differ by roughly 295 megabytes. A limit set from a monitoring reading in GiB and typed as G is under-provisioned by that margin from the first deploy, and the symptom is an intermittent restart rather than an error anybody traces back to a manifest.

Writing the constant so the next reader can check it

In code the expression beats the literal. 1024 * 1024 and 1 << 20 both state what the value is and let a reviewer verify it without counting zeros, while 1048576 sitting next to 10485760 in a config table is a diff nobody catches. Languages with digit separators help — 1_048_576 — but the multiplication still says more, because it carries the base along with the number.

The other half of the discipline is naming. A field called maxBytes cannot be handed a mebibyte figure by mistake; a field called maxSize can, and will. Where a value crosses a boundary — a form, an environment variable, an API — the unit belongs in the name, because that is the only place a caller reliably reads it.

The MiB figure you were handed was already binary

The number arriving at this conversion usually came from something that measures in binary units by default. free reports in kibibytes unless told otherwise. /proc/meminfo prints kB and means KiB. top and ps show resident set size in KiB. Container runtimes report limits and usage in bytes, and the dashboards above them display MiB.

That is convenient: multiplying that reading by 1,048,576 gets you back to the exact byte figure the kernel had, with nothing lost but the digits the display dropped. It is only when a decimal-megabyte number from a spec sheet, a contract or a marketing page enters the same field that the two conventions collide, and that number should be converted deliberately rather than typed with an M after it.

Round mebibytes, untidy bytes, and the 700 MiB example

A tidy figure in MiB is an untidy one in bytes, and there is no arrangement of the two scales where both look neat. 700 MiB is 734,003,200 bytes. 250 MiB is 262,144,000. 1.5 MiB is 1,572,864. None of those look like numbers anybody chose, and all of them are exact.

The classic worked example is the compact disc: an eighty-minute data disc holds 360,000 sectors of 2,048 bytes, which is 737,280,000 bytes, or 703.125 MiB. The disc has been called a 700 MB disc for thirty years, the figure is neither a decimal 700 MB nor a binary 700 MiB, and it is a good reminder that a familiar capacity is often a rounded label rather than a unit.

Alignment is the reason MiB divides cleanly into everything below it

One mebibyte is exactly 256 memory pages of 4,096 bytes, 2,048 disk sectors of 512 bytes, or 256 filesystem blocks on a default ext4 volume. Every boundary underneath a mebibyte figure falls on a whole number, which is why buffer sizes, ring buffers, mmap regions and partition offsets are specified in binary units rather than decimal ones.

A decimal megabyte divides into none of them. 1,000,000 bytes is 244.14 pages and 1,953.125 sectors, so a buffer of that size straddles a page boundary at one end and wastes part of a block at the other. The binary unit is not merely traditional here — it is the one that matches the thing being allocated, and that is why this conversion is the one worth having exact.

The boundary values a test should actually use

A limit expressed in mebibytes deserves three test fixtures rather than one, and their sizes come straight out of this conversion. For a 10 MiB cap the interesting bytes are 10,485,759, 10,485,760 and 10,485,761: one below, exactly at, one above. Whether the boundary itself should pass depends on whether the check is a comparison or a strict one, and that is precisely the question a test at the boundary answers and a test at 5 MiB does not.

Generating those fixtures is worth doing by byte count rather than by unit, for the same reason the constant is. A file created with a size argument in a friendly unit inherits whatever base the creating tool used, so a fixture intended to be one byte over a limit can land four per cent under it. Create the file with an explicit byte length, assert its length in the test, and the fixture is then evidence rather than an assumption.

Convert MiB to B: common questions

How many bytes are in one MiB exactly?

1,048,576 — that is 1,024 × 1,024, or 2 to the twentieth power. There is nothing rounded about it, which is the reason to use the unit at all: a mebibyte has one value, whereas a megabyte has two depending on who is speaking.

Does `client_max_body_size 10m` in nginx mean 10 MB or 10 MiB?

It means 10 MiB — 10,485,760 bytes. The k and m suffixes in nginx sizes are 1,024-based, as they are in the JVM heap flags and in PHP’s shorthand notation. If a specification hands you a limit in decimal megabytes, converting it before you write the config is a real step, not a pedantic one.

What is the difference between 512Mi and 512M in Kubernetes?

512Mi is 536,870,912 bytes and 512M is 512,000,000 — a gap of about 4.9 per cent, in the same field, distinguished by one letter. On a memory limit that difference decides whether a container is terminated, and the manifest that gets it wrong is valid YAML that passes review.

Why does `dd bs=1M` copy a different amount than `dd bs=1MB`?

GNU `dd` reads `1M` as 1,048,576 bytes and `1MB` as 1,000,000. Both suffixes are documented and both are accepted, so a block-size argument copied from one script into another can change the transfer size by 4.86 per cent without any warning.

Should I write 1048576 or 1024 * 1024 in code?

Write the arithmetic. `1024 * 1024` or `1 << 20` says what the number is, and a reviewer can check it at a glance; a bare 1048576 has to be counted digit by digit, and 10485760 next to 1048576 is the kind of pair that survives review. Comments help less than an expression that cannot be misread.

Why do round MiB figures become untidy byte counts?

Because the two scales share no factors beyond powers of two. 700 MiB is 734,003,200 bytes, which looks arbitrary and is exact. The rule of thumb is that a tidy number on one side guarantees an untidy one on the other, so an unremarkable-looking byte count is not evidence of a mistake.

Going the other way: Byte to Mebibyte

One B is 9.53674e-7 MiB. It is the same relationship read backwards, so an answer from one page put through the other has to come back to where it started.

Where these figures come from

The claims this page makes about data units are checkable, and these are the documents that settle them.

How this page works

The factor is a constant in the page and the arithmetic is four operations, so nothing is sent anywhere and nothing needs to be. The number you type never leaves the browser — there is no request for it to travel in.