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
    New Coder
    Join Date
    Mar 2004
    Posts
    95
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Simple number problem

    Another basic question .. I need to divide a number by 5 and I want to trim anything after a decimal point in the answer. eg 18 / 5 = 3.6. I want the make the answer 3. Is there a simple way to do this?

  • #2
    Senior Coder
    Join Date
    Feb 2004
    Posts
    1,206
    Thanks
    0
    Thanked 0 Times in 0 Posts
    There are a few different things you can do:
    25/7 // float(3.5714285714286)
    (int) (25/7) // int(3)
    round(25/7) // float(4)

    I got this from:
    http://php.oregonstate.edu/manual/en...es.integer.php

    Hope that helps,
    Sadiq.

  • #3
    Regular Coder
    Join Date
    Mar 2004
    Posts
    115
    Thanks
    0
    Thanked 0 Times in 0 Posts
    try floor();

  • #4
    New Coder
    Join Date
    Mar 2004
    Posts
    95
    Thanks
    8
    Thanked 0 Times in 0 Posts
    excellent ... floor() does it nicely, thanks.


  •  

    Posting Permissions

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