Welcome! Log In Create A New Profile

Advanced

Compare calculation

Posted by Gsmuser 
Gsmuser
Compare calculation
June 15, 2009 10:06AM
how can i compare a serries of numbers and find the closest match
for eampel:
number1 is string =30 its also the string that we want to macth closest

number2 is string =38
number3 is string =25
number4 is string =21
number5 is string =28
number6 is string =33
number7 is string =59
closest macth woot be = string number 5 compared with string1
Ps the content of the number strings are from input they can be anything



Edited 4 time(s). Last edit at 06/15/2009 09:40PM by Gsmuser.
Gsmuser
Re: Compare calculation
June 15, 2009 09:39PM
is this somthing that cant be done?
Frans
Re: Compare calculation
June 15, 2009 09:48PM
Hello,

Place the values in an array
Calculate the difference with nbr1 and nbr 2
Remember the difference

In a loop Calculate each other difference (1 and 3, 1 and 4 etc)
If there is a smaller difference than nbr1 and nbr2 then rember the new nbr and the difference.
And so on.

If you compared all differences then you should get the closest nbr.
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: