You can go back to the main page of my GitHub site, or check out my other projects.

Introduction

There are some other similar programs available on the web, and I made a decision to write another such program in Java.

My aim is to make the most lightweight partition size calculator ever.

When do I need to use this?

This is a good question. But to explain this bullshxx, I'm going to write very long.

Windows uses very weird formulas for converting sizes between megabytes (MB) and gigabytes (GB).

Since Windows 9x, when users make partitions using the FDISK utility, normally they will enter 10240 for 10 GB.

P/S: 1 GB is 1024 MB, in exact.

But in Windows Explorer, it shows up as 9.98 GB, instead of 10.00 GB. This causes problems with some OCD patients. Lel.

Then, some people found a solution. Assume G is the desired partition size in GB, the formula is (G-1)*4+1024*G.

For example, 10 GB. G=10, (10-1)*4+1024*10 = 9*4+10240 = 36+10240 = 10276, so the correct size is 10276 MB.

The problem is solved for some time... Until NTFS appeared. The above formula only works for FAT32 file system.

When users enter 10276 for 10 GB and format that partition as NTFS, in Windows, it shows up as 10.01 GB or 10.02 GB...

Yup, OCD patients will be mad again. :p

So, some other people found another solution. This size is based on cylinder numbers.

Since a hard disk has 255 heads and 63 sectors, hence, the size per cylinder is 512*255*63 = 8225280 B = approximately 7.84423828125 MB.

And since in exact 10 GB is 10240 MB, so let's calculate the number of cylinders.

10240/7.84423828125 = 1305.416744475568004979769685652

Round up the number, no matter what. So, 1306.

Then, remultiply the number of cylinders that is rounded up with the size per cylinder, which is 7.84423828125 MB.

1306*7.84423828125 = 10244.5751953125

Again, round up the number, no matter what. So, 10245 MB.

Problem solved. 10 GB is 10276 MB for FAT32, and 10245 MB for NTFS.

I don't think you will want to calculate so hard every time you make partitions with hard disks... So, this program.

Additional Information (UEFI systems only)

In Windows 10 Setup (or maybe in Windows 7, 8.0 and 8.1 too), there is a step for partitioning. If the hard disk is empty, and you want to create the first primary partition, it will make extra 3 hidden partitions.

The first partition is the recovery partition (450 MB), followed by the EFI system partition (100 MB) for storing boot files, and finally, Microsoft reserved partition (16 MB). These 3 hidden partitions are created before your first primary partition.

And the size of primary partition will be deducted by the same amount used for the three partitions, which is 566 MB.

For example, the desired size for the first primary partition is 60 GB. The calculated size using the above formula is 61444 MB. You will need to enter 61444+566 = 62010 MB to get the primary partition displayed as 60.00 GB correctly.

P/S: Windows NT6 systems (Windows Vista, 7, 8.0, 8.1 and 10) only support NTFS for the system partition, with Windows NT6 installed on it.

References

Copyright Statements

Copyright © 2016 Lim Chunwei

This work is free. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See the COPYING.WTFPL file for more details.