The first time I lost marks over MB to GB, it was on a computer science quiz. I divided by 1,000, the marking scheme wanted 1,024, and I lost two easy points. A few years later I shipped a small script that showed file sizes to users, and someone reported that my "GB" didn't match what their operating system said. Same problem, different setting.
If you're a student, a developer, or someone who builds spreadsheets with file sizes in them, you need more than "divide by 1,000." You need to know which formula to use, how to write it in code, and how to label it so nobody gets confused. That's what this post covers. For the plain-English background on the two standards, the explainer on mb to gb conversion and the 1,000 vs 1,024 question is a good companion to this one.
The two formulas, written properly
Let me write the MB to GB formulas out the way I'd want them on an exam sheet.
Decimal (SI): GB = MB ÷ 1,000. In bytes: 1 MB = 1,000,000 bytes, 1 GB = 1,000,000,000 bytes
Binary (IEC): GiB = MiB ÷ 1,024. In bytes: 1 MiB = 1,048,576 bytes, 1 GiB = 1,073,741,824 bytes
The names matter. "MB" and "GB" are decimal units. "MiB" and "GiB" are binary units. The trouble starts because many programs and textbooks use "MB" and "GB" for the binary values too.
Where the binary names came from
For years, people used kilo, mega and giga to mean both powers of 10 and powers of 2. That ambiguity is why the same MB to GB question can have two answers.
According to NIST's reference page on prefixes for binary multiples, the International Electrotechnical Commission approved names and symbols for binary prefixes (kibi, mebi, gibi and so on) as an international standard in December 1998. The same page notes that these binary prefixes are not part of the International System of Units (SI).
So when you see MiB or GiB, the writer is being precise: they mean powers of 2. When you see MB or GB, you have to check the context.
Which MB to GB formula should you use?
Here's the MB to GB rule I follow, and the one I'd teach anyone studying for a test.
In exams and coursework
Use whatever your course defines. Many computer science courses still teach 1 GB = 1,024 MB, and the marking scheme follows the textbook. If the question uses MiB or GiB, it's definitely binary. If it's unclear, write your assumption on the paper: "Assuming 1 GB = 1,024 MB." Most markers will accept a clearly stated assumption.
In code
Pick a standard, use the correct unit label for it, and stay consistent. If you divide by 1,024, label it MiB or GiB. If you divide by 1,000, label it MB or GB. The bug I shipped years ago was dividing by 1,024 and labelling it "GB," so it didn't match tools that used decimal.
In spreadsheets and reports
Match the audience. If you're reporting storage use to people who buy drives, decimal lines up with packaging. If you're reporting memory use for a server team, binary is usually expected. Either way, put the unit in the column header.
MB to GB worked examples you can check by hand
Practising a few MB to GB conversions both ways is the fastest way to get comfortable.
*Example 1: 3,000 MB to GB
*
Decimal: 3,000 ÷ 1,000 = 3 GB
Binary: 3,000 ÷ 1,024 = 2.9297 GiB (rounded)
*Example 2: 8,192 MB to GB
*
Decimal: 8,192 ÷ 1,000 = 8.192 GB
Binary: 8,192 ÷ 1,024 = 8 GiB exactly
Notice how powers of 2 give clean binary answers. That's a nice exam shortcut: if the MB value is a power of 2 (512, 1,024, 2,048, 4,096), the question probably expects the binary formula.
*Example 3: 750 MB to GB
*
Decimal: 0.75 GB
Binary: 0.7324 GiB
*Example 4: going from bytes
*
If you start with bytes, convert straight to GB instead of stopping at MB. 5,368,709,120 bytes ÷ 1,073,741,824 = 5 GiB. In decimal, the same bytes ÷ 1,000,000,000 = 5.37 GB.
*Example 5: going backwards
*
To go from GB back to MB, multiply. 2.5 GB × 1,000 = 2,500 MB. 2.5 GiB × 1,024 = 2,560 MiB.
The ratio trick for exams
When I need to switch between the two answers quickly, I use the ratio between them.
1 GiB ÷ 1 GB = 1,073,741,824 ÷ 1,000,000,000 ≈ 1.0737
So a value in GiB is about 7.4% smaller as a number than the same amount in GB. If you've calculated 10 GB, the binary figure is about 10 ÷ 1.0737 ≈ 9.31 GiB.
For MB to GB specifically, where you're comparing MiB-to-GiB with MB-to-GB, the gap is 1,024 vs 1,000, which is 2.4%. That's why the two MB to GB answers for small numbers look so close: 1,000 MB is 1 GB or about 0.977 GiB.
Writing MB to GB in Python
Here's how I write the MB to GB conversion in Python, with clear names so nobody mixes the units up.
def mb_to_gb(mb: float) -> float:
"""Decimal: megabytes to gigabytes."""
return mb / 1000
def mib_to_gib(mib: float) -> float:
"""Binary: mebibytes to gibibytes."""
return mib / 1024
def bytes_to_human(n: int, binary: bool = False) -> str:
base = 1024 if binary else 1000
units = ["B", "KiB", "MiB", "GiB", "TiB"] if binary else ["B", "KB", "MB", "GB", "TB"]
size = float(n)
for unit in units:
if size < base or unit == units[-1]:
return f"{size:.2f} {unit}"
size /= base
print(mb_to_gb(3500)) # 3.5
print(mib_to_gib(3584)) # 3.5
print(bytes_to_human(5_368_709_120, binary=True)) # 5.00 GiB
print(bytes_to_human(5_368_709_120)) # 5.37 GB
A few things I do on purpose here:
The function names say which system they use.
The binary version uses binary labels (KiB, MiB, GiB).
The formatting function takes a flag, so the caller decides which standard to show.
Getting a file size in Python
If you want a real file's size, os.path.getsize() returns bytes. Convert from bytes, not from a rounded MB value.
import os
size_bytes = os.path.getsize("video.mp4")
print(f"{size_bytes / 1_000_000_000:.2f} GB") # decimal
print(f"{size_bytes / 1_073_741_824:.2f} GiB") # binary
Writing MB to GB in JavaScript
JavaScript follows the same MB to GB idea. Here's a small helper I've used in front-end code that shows upload sizes.
function mbToGb(mb) {
return mb / 1000; // decimal
}
function mibToGib(mib) {
return mib / 1024; // binary
}
function formatBytes(bytes, binary = false) {
const base = binary ? 1024 : 1000;
const units = binary
? ["B", "KiB", "MiB", "GiB", "TiB"]
: ["B", "KB", "MB", "GB", "TB"];
let i = 0;
let size = bytes;
while (size >= base && i < units.length - 1) {
size /= base;
i++;
}
return ${size.toFixed(2)} ${units[i]};
}
console.log(mbToGb(1500)); // 1.5
console.log(formatBytes(2147483648, true)); // "2.00 GiB"
console.log(formatBytes(2147483648)); // "2.15 GB"
A note on upload limits
When I set an upload limit in code, I write it in bytes and add a comment saying which unit the user sees. For example, a "25 MB" limit in decimal is 25,000,000 bytes, while "25 MiB" is 26,214,400 bytes. If the form says 25 MB and the code checks 25 MiB, users can upload slightly more than the label says. It's minor, but it's the kind of mismatch that turns into a support ticket.
Writing MB to GB in spreadsheets
Spreadsheets are where I see the most silent MB to GB mistakes, because a formula gets copied down a column and nobody checks the unit.
Basic formulas
If column A holds MB values:
Decimal GB: =A2/1000
Binary GiB: =A2/1024
If column A holds bytes:
Decimal GB: =A2/10^9
Binary GiB: =A2/2^30
Using 10^9 and 2^30 instead of typing out the long numbers makes the formula easier to audit. Anyone reading it can see which system you meant.
Rounding in sheets
Wrap the formula in ROUND for cleaner output: =ROUND(A2/1000, 2). I round only the final displayed value, never intermediate results that feed into other formulas.
Label the header
I always write headers like "Size (GB, decimal)" or "Size (GiB)." It feels fussy until someone forwards your sheet to a team that assumes the other standard.
MB to GB on the command line
If you work in a terminal, you'll run into both standards there too, and the tools don't always tell you which one they're using unless you look.
Disk usage with du and df
On Linux, GNU du -h and df -h print "human readable" sizes using powers of 1,024, but they label them with K, M and G. So when du -h says a folder is 3.5G, that's 3.5 GiB. Adding --si switches both commands to powers of 1,000, which gives you decimal GB instead.
du -sh ~/projects # binary, e.g. 3.5G (really GiB)
du -sh --si ~/projects # decimal, e.g. 3.8G
du -sb ~/projects # exact bytes, best for your own MB to GB math
I use du -sb when I want an exact byte count and then do the MB to GB conversion myself. It removes any doubt about which base the tool picked.
Why the two outputs differ
Run both commands on the same folder and the decimal number will always be bigger. Nothing changed on disk. The decimal MB to GB answer uses a smaller unit, so the number goes up. Seeing both outputs side by side is one of the fastest ways I know to make the 1,000 vs 1,024 difference click for a student.
MB to GB in SQL and data work
Databases and data tools report sizes too, and the same rules apply.
*Database size queries
*
Most database systems give you table or database sizes in bytes, then let you format them. When I write a size report query, I convert from bytes and put the unit in the column alias, for example size_gb_decimal or size_gib. That way, nobody reading the report has to guess which MB to GB rule I used.
SELECT table_name,
total_bytes / 1000000000.0 AS size_gb_decimal,
total_bytes / 1073741824.0 AS size_gib
FROM my_table_sizes;
The table and column names here are placeholders, so swap in whatever your database exposes.
*Dataset sizes in pandas
*
In pandas, DataFrame.memory_usage(deep=True) returns sizes in bytes. When I'm checking whether a dataset will fit in memory on a laptop, I sum that result and convert to GiB, because RAM is sized in binary.
import pandas as pd
df = pd.read_csv("data.csv")
total_bytes = df.memory_usage(deep=True).sum()
print(f"{total_bytes / 2**30:.2f} GiB in memory")
A CSV that's 900 MB on disk can take more room once loaded, depending on the column types. So I measure the loaded size instead of guessing from the file size. The MB to GB check on the real number tells me whether I need to load the data in chunks.
How I explain MB to GB in a presentation or viva
If you have to explain this topic out loud, keep it to three sentences. Here's the version I use:
"Storage makers count in powers of 10, so 1 GB is 1,000 MB. Computers often count in powers of 2, so 1 GiB is 1,024 MiB. The bytes are the same, only the unit size changes, which is why a drive can look smaller on your computer than on the box."
Then show one worked MB to GB example, like 2,048 MB giving 2.048 GB in decimal and 2 GiB in binary. One clear example does more than a slide full of definitions.
Common MB to GB mistakes students and coders make
*Dividing twice by the wrong base
*
Going from bytes to GB in binary means dividing by 1,024 three times (bytes to KiB to MiB to GiB). A common slip is dividing by 1,024 once and by 1,000 twice, which gives a number that matches neither standard.
*Mixing bits and bytes
*
MB is megabytes. Mb is megabits. 1 byte = 8 bits. Network speeds are usually in Mbps. If an exam question asks how long a 400 MB file takes on a 100 Mbps link, convert first: 400 MB × 8 = 3,200 Mb, then 3,200 ÷ 100 = 32 seconds (ignoring overhead).
*Rounding too early
*
If you round 1,536 MB to "about 1.5 GB" and then multiply by 40 files, you're off. Do the multiplication in MB first, then do one MB to GB conversion at the end.
*Using GB labels for binary values
*
This is the mistake I made in my script. If you divide by 1,024, use MiB and GiB. If your users expect "GB," divide by 1,000 instead.
*Ignoring capital letters
*
Lower-case "mb" isn't a real unit symbol in most standards, and "Mb" means megabits. In formal answers, write MB for megabytes and MiB for mebibytes.
MB to GB conversion table for study and reference
Here's an MB to GB reference table that shows both standards side by side. Values are rounded to 4 decimal places.

The power-of-2 rows (128, 256, 512, 1,024, 2,048, 4,096) give clean binary results. That pattern shows up a lot in exam questions about memory and in RAM sizes.
How memory and storage differ in practice
Students often ask why RAM sizes are always neat numbers like 8 GB or 16 GB, while drives come in sizes like 500 GB or 1 TB.
RAM is built in powers of 2 because of how memory is addressed. So an "8 GB" RAM stick is really 8 GiB, which is 8,192 MiB.
That's why the binary MB to GB formula feels natural for memory.
Storage drives are labelled in decimal by their makers. So a "500 GB" drive holds 500,000,000,000 bytes, which shows as about 465 GiB. That's why decimal feels natural for storage, and why computers that report in binary make drives look smaller.
When you see a question about RAM, lean binary. When you see a question about drive capacity on a label, lean decimal. And if the question says which one to use, follow it.
A quick self-test
Try these before checking the answers below. I'd do them on paper.
- Convert 6,144 MB to GB using the binary formula.
- Convert 6,144 MB to GB using the decimal formula.
- How many MiB are in 3.5 GiB?
- A file is 2,684,354,560 bytes. What is it in GiB?
A 250 MB file is sent over a 50 Mbps connection. Roughly how many seconds does it take, ignoring overhead?
*Answers:
*6,144 ÷ 1,024 = 6 GiB
6,144 ÷ 1,000 = 6.144 GB
3.5 × 1,024 = 3,584 MiB
2,684,354,560 ÷ 1,073,741,824 = 2.5 GiB
250 × 8 = 2,000 Mb, then 2,000 ÷ 50 = 40 seconds
If you got all five, you're ready for most MB to GB questions on a test.
More MB to GB practice for exam week
When I was revising, the questions that tripped me up weren't the simple ones. They were the word problems where the MB to GB step was hidden inside something else. Here are a few of that type, with my working.
Problem 1: photos on a memory card
A camera saves photos at 6 MB each. How many fit on a card that reports 7.5 GiB of free space?
My working: first turn 7.5 GiB into MiB, so 7.5 × 1,024 = 7,680 MiB. Then 7,680 ÷ 6 = 1,280 photos. Notice I converted the bigger unit down instead of converting each photo up. Going GB to MB keeps the numbers whole, which is easier to check than a long MB to GB decimal.
Problem 2: a backup that has to fit
You need to back up 18 files of 950 MB each to a drive with 16 GB free (decimal). Does it fit?
My working: 18 × 950 = 17,100 MB. The MB to GB conversion gives 17.1 GB. That's more than 16 GB, so it doesn't fit. If I'd rounded each file to "about 1 GB" first, I'd have got 18 GB and the right answer by luck. On a closer question, that rounding would have given the wrong answer.
Problem 3: RAM for a program
A program loads 3 data files of 1,536 MiB each into memory. The computer has 8 GiB of RAM, and the operating system uses 2 GiB. Is there enough room?
My working: 3 × 1,536 = 4,608 MiB. The binary MB to GB step gives 4,608 ÷ 1,024 = 4.5 GiB. Available RAM is 8 − 2 = 6 GiB. 4.5 GiB fits, with 1.5 GiB left over.
Problem 4: a download quota
A student network allows 5 GB of downloads per day (decimal). You've downloaded files of 1,250 MB, 830 MB and 2,400 MB. How much is left?
My working: 1,250 + 830 + 2,400 = 4,480 MB. The MB to GB answer is 4.48 GB. So 5 − 4.48 = 0.52 GB, or 520 MB, is left.
What these have in common
In every problem, I did the adding or multiplying in one unit first, then did a single MB to GB conversion at the end. That habit removes most of the mistakes I see in marked papers.
When I reach for a converter
I like doing the math by hand because it keeps me honest. But when I'm checking a long list of values, or switching between MB, MiB, GB, GiB and TB in one task, I use a memory unit conversion tool to double-check my numbers. It's a quick sanity check before I submit an assignment or merge code.
My checklist for clean MB to GB work
Before I hand in an MB to GB answer, publish a report, or push code, I run through this:
- I know which standard the context expects.
- My divisor matches that standard (1,000 or 1,024).
- My unit labels match the divisor (GB for decimal, GiB for binary).
- I converted from the rawest number available, ideally bytes.
- I rounded only the final result.
- I didn't mix bits and bytes. It takes about thirty seconds and has saved me from more than one wrong answer.
Conclusion
Most MB to GB mistakes come down to two things: using the wrong divisor, or using the right divisor with the wrong label. I've made both, once on a quiz and once in production code, and both were easy to avoid.
Learn the two formulas, use MiB and GiB when you mean binary, convert from bytes when you can, and write your assumption down when the question is vague. Do that, and your answers will hold up in an exam, in a code review, and in a spreadsheet someone else opens six months from now.
Frequently Asked Questions
*What is the formula to convert MB to GB?
*
For decimal units, divide MB by 1,000. For binary units, divide MiB by 1,024 to get GiB. Use whichever standard your course, tool or audience expects.
*Do exams use 1,000 or 1,024 for MB to GB?
*
Many computer science courses use 1,024, but it varies. Follow your textbook or course notes. If the question is unclear, state your assumption in your answer.
*What is the difference between MB and MiB?
*
MB is a decimal unit equal to 1,000,000 bytes. MiB is a binary unit equal to 1,048,576 bytes. A MiB is about 4.86% larger than a MB.
*When were binary prefixes like MiB and GiB introduced?
*
The International Electrotechnical Commission approved the binary prefixes kibi, mebi and gibi as an international standard in December 1998.
*How do I convert bytes to GB in Python?
*
Divide the byte count by 1,000,000,000 for decimal GB, or by 1,073,741,824 for binary GiB. You can get a file's size in bytes with os.path.getsize().
*How do I convert MB to GB in a spreadsheet?
*
If your MB values are in column A, use =A2/1000 for decimal GB or =A2/1024 for binary GiB. Label the column header with the unit you chose.
*Why is 8,192 MB exactly 8 GB?
*
8,192 is a power of 2, so dividing it by 1,024 gives exactly 8. In binary terms that's 8 GiB. In decimal terms, 8,192 MB is 8.192 GB.
*Why does RAM use binary sizes?
*
Memory is addressed in powers of 2, so RAM capacities naturally come in binary sizes. That's why RAM is sold in sizes like 8 GB and 16 GB, which are really 8 GiB and 16 GiB.
*Is Mb the same as MB?
*
No. Mb means megabits and MB means megabytes. One byte is 8 bits, so 1 MB equals 8 Mb. Network speeds are usually given in Mbps.
*How many GiB is 1 GB?
*
1 GB is about 0.9313 GiB. That's because 1 GB is 1,000,000,000 bytes and 1 GiB is 1,073,741,824 bytes.
Top comments (0)