Skip all the multiplications, max()/min() function calls, or logical AND (&&), and just do
function in_range(_, __, ___) {
return ((_ = +_) < +__) < (_ <= +___)
}
in_range(n, 0.001, 0.009)
It works because the boolean outcome described by this triple compare chain is inquiring whether
n <= max is TRUE but also
n < min is FALSE
Which is same as inquiring about being within the [min, max] range. The logical equivalent is not(not A) and B, which is just another way of saying A and B. The comparison operators are so low-cost whether a short-circuiting && saves time is questionable.
0.0010
0.0011
0.0012
0.0013
0.0014
0.0015
.
.
.
0.0087
0.0088
0.0089
0.0090
A similar function can also be created for string comparisons in the same manner by removing the forced numeric coercions :
function in_range_str(_, __, ___) {
return (_ < __) < (_ <= ___)
}
So instead of having to invoke regex or check its byte ordinal value, one can test whether a byte is a uppercase letter in ASCII by doing
in_range_str(chr1, "A", "Z")