Jump to content
  • Advertisement

Archived

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

Ketay

Rounding

This topic is 5706 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!