To answer the question in short, here’s a table.
1 MB = 1,000 kB = 976.562 KiB = 1,000,000 B
1 MiB = 1,024 KiB = 1,048.576 kB = 1,048,576 B
1 KB = 1KiB = 1,024 B
The formula to convert SI to IEC:
x * (1000 / 1024)^n * 1000^(m - n)
where n is the exponent of the target unit, and m is the exponent of the original.
4 TB = 4 * (1000 / 1024)^4 * 1000^0 TiB ≈ 3.64 TiB
4 TB = 4 * (1000 / 1024)^3 * 1000^1 GiB ≈ 3725 GiB
The storage manufacturers use SI to measure and label the device, while most of the OS use IEC to measure and display the space. Thus, a 4 TB storage would be reported 3725 GiB in the system.
Note that some programs use base 1000 to convert IEC value, for example showing 4 TB as 3.725 TiB. This is incorrect.
However, the units commonly used in the network is much less confusing. It’s always 1000 based, for example, 1 Mb = 1000/8 MB. Oppositely, when speaking of RAM, IEC is always used, so an 8 GB RAM indicates the capacity of 8 GiB.
With the rapid growth of the data magnitude, the difference between SI and IEC measurements is no longer ignorable. To make things more complicated, another standard JEDEC B100.01 defines “K” as 1024, “M” as 1024 K, and “G” as 1024 M. This system is used by Windows Explorer, so KB in Windows Explorer equals to KiB, and MB is in fact MiB.