# Round a number to values in an array

**URL:** <https://forum.kirupa.com/t/round-a-number-to-values-in-an-array/314209>\
**Category:** flash\
**Created:** [September 21, 2010, 7:30pm UTC](https://forum.kirupa.com/t/round-a-number-to-values-in-an-array/314209 "2010-09-21T19:30:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![xbox\_hacker](https://avatars.discourse-cdn.com/v4/letter/x/d07c76/32.png) [@xbox\_hacker](https://forum.kirupa.com/u/xbox_hacker)\
**Post date:** [September 21, 2010, 7:30pm UTC](https://forum.kirupa.com/t/round-a-number-to-values-in-an-array/314209/1 "2010-09-21T19:30:31Z")

</div>

lets say i do some simple AS3 math and get a Number of 199.  
How can i use a Array with values of “preferred” numbers, compare the 199 to the array and round up or down to the closest value in the array?

var myNumber:Number = 199;  
var myArray = new Array(100,175,190,200);  
var myMatch = 200;  
output.text = myMatch;

I want to round the 199 up to 200(closest match) and have the myMatch = the rounded number from the array.

Thank You!!!
