in reply to Testing whether a value is in a range.
If speed is a real issue you might consider wasting memory/disk and pre-generate a (possibly partial) lookup table rather than doing lots of range comparisons.