I’m trying to get rough greater than and less than values to compare latitude and longitude. I need to be able to pass in a latitude, longitude and number of digits to which to round. If I have these values for example:
18.363285 -67.18024
18.448619 -67.13422 <----- Only second value matched
18.498987 -67.13699 <----- Both values matched
18.465162 -67.141486
18.182151 -66.9588
Selecting the middle as one to match, I want to pass in 18.49(1234567) as latitude, -67.13(1234567) as longitude and 2 as the number of decimals to which to round. I’m planning to round the given latitude and longitude down by 2 places to get the lower bound, then add 0.02 to this to get the upper bound.
I’m stuck on the last part. I can’t think of a mathematical function which takes 4 as an input and returns 0.00004.
Unless I’m overcomplicating this and there’s a simple way to match a set of values within a tolerance.
EDIT: For example, I need to pass in these numbers and get these values back:
In Out
1 0.01
2 0.001
3 0.0001
4 0.00001
5 0.000001
6 0.0000001
1 Answer