Jump to content
Sign in to follow this  
AXE

Turning a number into an array...

Recommended Posts

How do you take a number and separate each digit to make

an array. for example, i want to change 21 into [2,1]

Any help would be great smile_o.gif

Share this post


Link to post
Share on other sites

i really have no time to help extensively, but here are some hints i can give.

following are not tested and is pulled from my brain.

21/10 will return 2

21%(10*2) will return 1

"format" funtion returns string

and make an array out of it.

hopefully above method mught work. where bn880 when you need him?

Share this post


Link to post
Share on other sites

thanks I got it working now smile_o.gif the only thing I need to know

now is how to round numbers eg. change 3.432432 to 3 but

also have 3.785645 return as 3.

*edit never mind, fixed it smile_o.gif

Share this post


Link to post
Share on other sites

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_number = random 100

_rest = _number mod 1

_number = _number - _rest

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×