Posting this in the general section because it isn't language-specific.
I think my caffeine levels are low, because the penny just isn't dropping with this one. I know its easy but I can't get it.
Imagine you have two numbers - any two numbers. For an example let's say 32, and 40. The first is always lower than the second.
32 represents 0%. 40 represents 100%. Therefore 50% is 36 (half way between).
With me so far?
I need a formula that will take any two floats I give to it, then return a float between 0 and 1 based on a third float, which is always somewhere between the first and second floats.
I.e. Using 32.0 and 40.0, I give it 38.0, it returns 0.75.
Note; I'm using whole numbers here to keep the examples simple. The values involved could be floats to any number of decimal places, so lookup tables and such are out of the question.
I think my caffeine levels are low, because the penny just isn't dropping with this one. I know its easy but I can't get it.
Imagine you have two numbers - any two numbers. For an example let's say 32, and 40. The first is always lower than the second.
32 represents 0%. 40 represents 100%. Therefore 50% is 36 (half way between).
With me so far?
I need a formula that will take any two floats I give to it, then return a float between 0 and 1 based on a third float, which is always somewhere between the first and second floats.
I.e. Using 32.0 and 40.0, I give it 38.0, it returns 0.75.
Note; I'm using whole numbers here to keep the examples simple. The values involved could be floats to any number of decimal places, so lookup tables and such are out of the question.