# Restrict a number to a range? (0 - 1, for example)

**URL:** <https://forum.kirupa.com/t/restrict-a-number-to-a-range-0-1-for-example/201021>\
**Category:** flash\
**Created:** [September 17, 2006, 9:38pm UTC](https://forum.kirupa.com/t/restrict-a-number-to-a-range-0-1-for-example/201021 "2006-09-17T21:38:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anogar](https://avatars.discourse-cdn.com/v4/letter/a/ed655f/32.png) [@Anogar](https://forum.kirupa.com/u/Anogar)\
**Post date:** [September 17, 2006, 9:38pm UTC](https://forum.kirupa.com/t/restrict-a-number-to-a-range-0-1-for-example/201021/1 "2006-09-17T21:38:09Z")

</div>

How would I restrict this variable:

```auto

this.mousePercent = _root.portfolio._xmouse/500;

```

so that it can’t get below 0 or greater than 1?

My brain is fried and I can’t figure it out. :-/
