Maths Problem

Author
Discussion

ecs

Original Poster:

1,296 posts

177 months

Sunday 4th September 2016
quotequote all
Guess this is the right place for this? I need to figure out an algorithm which calculates the following:

If you’ve got a min value, a max value and a number between those values, how would you calculate the number between max and min as a percentage?

e.g. if min=-100, max=100 and n=0, n as a percentage should be 50%

Min and max can be positive or negative values and I guess it ought to be possible for min to be greater than max if it doesn't make things even more complicated.

I'm a bit out of my comfort zone on this one, so does anyone here know how to solve this?

Dr Jekyll

23,820 posts

268 months

Sunday 4th September 2016
quotequote all
confused

Hopefully Stephen Hawking is in the mood for a challenge.

HappyMidget

6,788 posts

122 months

Sunday 4th September 2016
quotequote all
Your range is the total for the base of the percentage (max - min), and the difference of the mid value from the min is thetop half of the fraction (mid - min). You then get ((mid - min)/(max - min)) * 100. I think.

philv

4,243 posts

221 months

Sunday 4th September 2016
quotequote all
N2 > n > n1

(N-n1)/((N2 - n1)/100)

Ie same as prev post.

Edited by philv on Sunday 4th September 20:03

JungleJim

2,353 posts

219 months

Wednesday 14th September 2016
quotequote all
But what about when min is greater than max?

Einion Yrth

19,575 posts

251 months

Thursday 15th September 2016
quotequote all
JungleJim said:
But what about when min is greater than max?
This is Science!, most will politely ignore that particular idiocy.

V8LM

5,269 posts

216 months

Saturday 17th September 2016
quotequote all
JungleJim said:
But what about when min is greater than max?
Or when min equals max?

AstonZagato

13,035 posts

217 months

Saturday 17th September 2016
quotequote all
Excel has a handy function for this:
https://support.office.com/en-us/article/PERCENTRA...