Link to home
Start Free TrialLog in
Avatar of Jedidia
JedidiaFlag for United States of America

asked on

Find closest value in a multidim array

I have a multidim array that has hundreds of records and it.
For array(i, 2) the data looks like this:

array(0,2) = 121
array(1,2) = 3121
array(2,2) = 5121
array(3,2) = 6121
......

I perform a calculation and get a random value of 4010 and want to search the array(I, 2) for the closest (rounded up) value in the array.

What's the best way of going about this.

Thanks
Avatar of Kyle Abrahams, PMP
Kyle Abrahams, PMP
Flag of United States of America image

Is the array guaranteed to be sorted?

And when you say rounded up the 4010 becomes 5121?
Avatar of Jedidia

ASKER

no sorting of the array.

I actually don't care about the calculated value of 4010...I am just looking for the closest value (rounded up) in the array.
ASKER CERTIFIED SOLUTION
Avatar of Kyle Abrahams, PMP
Kyle Abrahams, PMP
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial