Blitz maths question...

Blitz3D Forums/Blitz3D Beginners Area/Blitz maths question...

There is a little formula that I learned in the 5th grade that has helped when figuring out percentages, as well as other fractions.
Assuming A/B = C/D
The numerator of the left fraction multiplied by the denominator of the right fraction will always equal the numerator of the right fraction multiplied by the denominator of the left. So if any value is missing, it can be calculated with the other three.
In other words:

A*D = B*C
A = (B*C)/D
B = (A*D)/C
C = (A*D)/B
D = (B*C)/A

So if you want to find out what is 17/34ths of 96, the equation would be written like this:
17/34 = X/96
X = (17*96)/34 = 48

To use percentages, just replace A with Current, B with Max, C with the percentage, and D with 100.
Current/Max = Percent/100
So to find out what percentage 20 is of 500
20/500 = X/100
X = (20*100)/500 = 4%

To find out what 5% of 250 is
X/250 = 5/100
X = (250*5)/100 = 12.5

To find out what number 18 is 36% of:
18/X = 36/100
X = (18*100)/36 = 50

This little formula comes in handy in several situations. For example, I have a progress bar which is 512 pixels wide. I have finished downloading 10,496 bytes of a 1,453,687 byte file. How many pixels do I need to shade in to represent the number of bytes downloaded?
Downloaded/FileSize = Shaded/BarSize
10,496/1,453,687 = X/512
X = (10,496*512)/1,453,687 = 4 pixels (rounded to the nearest pixel)