How can i find nearest number in Map or Array

Hi I am trying to find nearest number in array please give me some inputs

like in above if i enter 500 it should give lower number as 450 and greater number as 520

And also if 500 is present in array output will be 500

Like this:

Do you want to know which numbers it’s between, or just the lowest nearest?

I tried like this for getting lower nearest number

How can i get only lower nearest value.In some cases it is giving greater nearest value

there will be two return values one is greater nearest number and other is lower nearest number

and if input is there in array then both return values will be the same

The above works. Tried it a different way, but it’s just as messy…

Not the height of elegance ( working on it ):

If you remove the print from the completed pin, and put it between the StopLoop node and the loop, it only reports if it finds something… :slight_smile:

Link: Nearest number in Map or Array posted by anonymous | blueprintUE | PasteBin For Unreal Engine