Avatar of Jedidia
Flag 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.

.NET ProgrammingVisual Basic.NET

Avatar of undefined
Last Comment
Kyle Abrahams

8/22/2022 - Mon
Kyle Abrahams

Is the array guaranteed to be sorted?

And when you say rounded up the 4010 becomes 5121?

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.
Kyle Abrahams

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy