oposite of %

Discussion in 'PHP' started by alarik, May 13, 2007.

  1. #1
    hi people.I want to divide 2 numbers and to get the full integer of the result,not with comas.for example i wnt to divide 10 with 3 and i want the result to be 3 ,not 3,1 or whatever it is...I knew this kind of things I just can't remember it:(.it was the oposite of % :(
     
    alarik, May 13, 2007 IP
  2. alarik

    alarik Active Member

    Messages:
    382
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #2
    nevermind,it's round(value)
    ;)
    cheers
     
    alarik, May 13, 2007 IP
  3. CodyRo

    CodyRo Peon

    Messages:
    365
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #3
    There is also two other functions that might help if you want to always round up or down.

    ceil() - Always rounds up
    floor() - Always rounds down
     
    CodyRo, May 13, 2007 IP
  4. alarik

    alarik Active Member

    Messages:
    382
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #4
    :) thank you very much
     
    alarik, May 13, 2007 IP
  5. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I know you've already solved your problem but the % operator only ever gives you the remainder. 10%3 is 1. 10%4 is 2. 10%5 is 0. etc

    To get the number of times the whole number is in another number, you just do a normal division and floor it.
    floor(10/3) = 3
    floor(10/4) = 2
    floor(10/5) = 2
     
    rodney88, May 13, 2007 IP