Best or closest match operator


#1

Hi. Does NSB have a function or operater that will for example: 3 values stored, one in A, one in B and one in C.
B is a fixed value and I want to find the best or closeset match to B from either values in A or C.

Thanks
Will.


#2

Would depend on what values you are storing? Probably just write a function to take care of ti? Really depends on what your are storing in A, B and C I think


#3

Hi John, thanks for getting back to me. I’m just storing numbers up to three decimal places.


#4

So you are just looking for the closest number between A or C to meet the value stored in B?


#5

Yes. I know i could just subtract A and C from B and just use the one with the smalest value but I was just wondering if there was a nicer way to do this where I wouldn’t have to worry about the signs of the values (+ or -)


#6

https://wiki.nsbasic.com/Abs

Absolute will help you out. Abs(-10) will return 10. Abs(10) will also return 10.