j-man 0 Posted February 14, 2004 I have a script that creates a random number. The problem is that it creates numbers like 12.5334, 53.242, etc... Is it possible to have those numbers rounded to the nearest whole number thanks Share this post Link to post Share on other sites
vektorboson 8 Posted February 14, 2004 I have a script that creates a random number. The problem is that it creates numbers like 12.5334, 53.242, etc... Is it possible to have those numbers rounded to the nearest whole number thanks <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_number = _number - (_number % 1); Share this post Link to post Share on other sites
Donnervogel 0 Posted February 14, 2004 that's not the nearest whole number btw. that's the last whole number. example: 9.999 is 9 then. and not 10. normally it doesn't matter but one should know what he's doing Share this post Link to post Share on other sites
vektorboson 8 Posted February 14, 2004 that's not the nearest whole number btw. that's the last whole number.example: 9.999 is 9 then. and not 10. normally it doesn't matter but one should know what he's doing You're right, I haven't read carefully, my apologies! Â <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _number = (_number+0.5) - ((_number+0.5) % 1); Share this post Link to post Share on other sites