in reply to Check whether two numbers are within a range
DB<54> $b=3.1565323 DB<55> $a=3.1566789 DB<56> p abs(1e5*($b-$a)) <1 DB<57> p abs(1e5*($b-$a)) 14.660000000033 DB<58>
of course you could avoid the multiplication by providing an accurate threshold smaller than 1.
It'll become more complicated with two coordinates, than I'd say Pythagoras is accurate enough°
Pythagoras sqr( d_x ** 2 + d_y ** 2 ) with d_ for delta= abs(c0-c1)
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
°) even for spherical coordinates of that size (but don't use this for the distance between New York and Seattle, you might fall off the edge of the world)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Check whether two numbers are within a range
by stevieb (Canon) on Feb 26, 2021 at 16:56 UTC | |
by LanX (Saint) on Feb 26, 2021 at 23:18 UTC |