Archived

This topic is now archived and is closed to further replies.

Ketay

Rounding

Recommended Posts

Language: PHP What are the things to round, so like if $iteminfo[cost] == 100; and we were to do: $sellprice = $iteminfo[cost] / 6; How do we do a round UP and a round down, I cant seem to find it in the docs at php.net...... Probably cuz I dunno wht it would be under, but I checked like everything under variables >.< So ya, if anyone could help, please do ^^; -Moo-

Share this post


Link to post
Share on other sites
Just do some tricks with modulo:


if( $iteminfo[cost] % 6 > 2 )
$sellprice = $iteminfo[cost] / 6 + 1;
else
$sellprice = $iteminfo[cost] / 6;

Share this post


Link to post
Share on other sites