Expand|Select|Wrap|Line Numbers
- code const integer reading[5] ={12, 96, 147, 245, 747}; // sorted numerically
- code const integer result[5] ={5, 10, 15, 20, 25}; // sorted numerically
- get look-up value for reading[] (for example 120)
- find last value in reading[] below this (for example 96)
- return equivalent value from result[] (for example 10)
The tables will in reality have up to 100 entries. My plan was to iterate through reading[] and find when the number is bigger, then step back one. Is this OK, or is there a better way? Should I consider hash tables?