When we purchase storage, we typically are advertised storage of 500GB, 1TB, 2TB and so on. However, when you actually install it into your computer, your 500GB HDD will actually show up as 465GB. Why?
It has to do with the way people and computers use numbers and do math.
When we purchase storage, we typically are advertised storage of 500GB, 1TB, 2TB and so on. However, when you actually install it into your computer, your 500GB HDD will actually show up as 465.66GB. Why?
It has to do with the way people and computers use numbers and do math. Humans use a numbering system called Base10 (0,1,2,3,4,5,6,7,8,9) whereas computers use binary or Base2 (0,1). Therefore, when a computer calculates 1 kilobyte, it calculates it as 1024 bytes. As we go up the ladder, a megabyte is 1024*1024 or 1,048,576 bytes. That's 48,576 more data than the hard drive manufacturers will give you. However, when we talk about kilobytes, we tend to mean 1000 bytes, but that is not really how it works.
Computers use 1024 because they use exponents of 2 to count. 2^0=1, 2^1=2, 2^2=4 and so on to 8, 16, 32, 64, 128, 256, 512, 1024. So after using 11 bits, we now have our value for a kilobyte, or 11 "1s".
So back to our example of the 500GB HDD with only 465.66 available, let's put our math to the test. If a gigabyte is 1 billion bytes (1,000,000,000 bytes), then the Base2 number would actually be: 1024*1024*1024=1,073,741,824. If we multiply our value of a gigabyte times that available to us, 465.66*1,073,741,824=499,998,617,763.84 bytes. This is just shy of our 500,000,000,000 bytes mark because I rounded down to 465.66GB instead of 465.6612873077393 GB which would have given us 500,000,000,000 bytes.
So to simplify our explanation, we get less data because of the way hard drive manufacturers define a kilobyte, megabyte, gigabyte, and terabyte using Base10 math (like we use) instead of binary math like computers use.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210 (2 * 3 * 5 * 7) or 2310 (2 * 3 * 5 * 7 * 11).
The larger templa…