# Checking a number is within a range or ranges

**URL:** <https://forum.kirupa.com/t/checking-a-number-is-within-a-range-or-ranges/276891>\
**Category:** flash\
**Created:** [December 4, 2008, 6:53pm UTC](https://forum.kirupa.com/t/checking-a-number-is-within-a-range-or-ranges/276891 "2008-12-04T18:53:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![the\_lar](https://avatars.discourse-cdn.com/v4/letter/t/90ced4/32.png) [@the\_lar](https://forum.kirupa.com/u/the_lar)\
**Post date:** [December 4, 2008, 6:53pm UTC](https://forum.kirupa.com/t/checking-a-number-is-within-a-range-or-ranges/276891/1 "2008-12-04T18:53:24Z")

</div>

Hi all,

I’ve got a quick question on the most efficient way of checking if a given number lies within a range or ranges of possible values.

I am loading an xml document which contains this snippet:

\<y-axis\>  
\<zone start=“1055” finish=“2055”/\>  
\<zone start=“2110” finish=“10000”/\>  
\</y-axis\>

There could be anything up to 5 zones. I basically need to check if a value of a number falls within any of these zones, the value is valid if it does, invalid if it doesn’t. Eventually this will be a user interface where a rectangular shape can be drawn and it kind of ‘snaps’ to the closest valid value on both the x and y axis.

So as I say, the first question is what is the most efficient way in AS3 of extracting whether or not a given value is within the safe-zones in the xml? Has anyone got any bright ideas?

Many thanks  
Kevin
