Omzy Posted December 22, 2009 Share Posted December 22, 2009 I need an IF statement that will round UP as follows: 50 / 2 = 25 49 / 2 = 25 But obviously must work for all numbers. ($i / 2 = $x) Quote Link to comment https://forums.phpfreaks.com/topic/186005-php-division/ Share on other sites More sharing options...
chriscloyd Posted December 22, 2009 Share Posted December 22, 2009 you want it to be divided by two or what? Quote Link to comment https://forums.phpfreaks.com/topic/186005-php-division/#findComment-982222 Share on other sites More sharing options...
Omzy Posted December 22, 2009 Author Share Posted December 22, 2009 Yes I want it divided by two. If the result is not a whole number then it should round up to the next whole number. Quote Link to comment https://forums.phpfreaks.com/topic/186005-php-division/#findComment-982226 Share on other sites More sharing options...
megaresp Posted December 22, 2009 Share Posted December 22, 2009 Yes I want it divided by two. If the result is not a whole number then it should round up to the next whole number. Have you tried the round() function? Details here... http://php.net/manual/en/function.round.php You can specify precision (# of decimal places - 0 in your case), and whether you want it to round up. down or whatever. I think this will do the job for you. Quote Link to comment https://forums.phpfreaks.com/topic/186005-php-division/#findComment-982231 Share on other sites More sharing options...
Daniel0 Posted December 22, 2009 Share Posted December 22, 2009 You may use ceil to do this. Quote Link to comment https://forums.phpfreaks.com/topic/186005-php-division/#findComment-982234 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.