|Problems? Is your data what you think it is?|
Check whether two numbers are within a rangeby stevieb (Canon)
|on Feb 26, 2021 at 16:07 UTC||Need Help??|
stevieb has asked for the wisdom of the Perl Monks concerning the following question:
Hey Monks, I come here seeking help from our mathematicians again, as I'm feeling apathetic today and am having a brain fart moment.
My objective is to find out if my car is parked within a 1.1 metre proximity of where it should be. This will identify whether the vehicle is in my garage or not. I then will read the vehicle's charge level, and using an LED strip on the garage wall, indicate the level on that strip, and if it's below a threshold, sound an audible alarm to remind me to plug the car in to recharge it. I will be using motion and sonar proximity sensors to identify when I've come into the house as to turn the warning off if I don't plug the car in (the car will indicate if the charger is plugged in via my software, and I'll disable the alert when this happens too).
Anyway, with GPS, the fifth decimal place indicates the 1.1 metre area I'm looking to find. My question is, how do I compare the known set location, say 3.1566789, with the actual location of the vehicle, say 3.1565323, and verify whether that they are within at least five decimal places of one another?
I don't know why I'm having this moment, I know it's a silly, easy thing. It'll likely come to me the second I hit submit. I know I could regex the numbers out, but I'd rather have a math calculation as I want to apply it to other areas.
I have no code for this simple example, so I'll just post the following to at least make it perlish.