Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts

    Using /2 coming up with decimals?

    I have a problems. If I divide a number in half and it's not even, it gives me decimals. Like this

    $points = 5;
    $newpoints = $member["points"]/2;

    Your new points are $newpoints

    Which comes up as 2.5

    I didn't write it the same way, but I am sure you understand. How can I get it to exclude decimals and round to the next number? So it would be a 2 or 3 ?

  • #2
    Senior Coder kbluhm's Avatar
    Join Date
    Apr 2007
    Location
    Philadelphia, PA, USA
    Posts
    1,509
    Thanks
    3
    Thanked 258 Times in 254 Posts

  • #3
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    That link doesn't work

  • #4
    Senior Coder kbluhm's Avatar
    Join Date
    Apr 2007
    Location
    Philadelphia, PA, USA
    Posts
    1,509
    Thanks
    3
    Thanked 258 Times in 254 Posts
    Ok, common sense tell you that the link is to php.net. The site seems to be down.

    So, once you are able to get to php.net, search for the round() function.

    Or, try a mirror:
    http://us2.php.net/round
    http://us3.php.net/round

    Or, let me just tell you: use round()


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •