Results 1 to 5 of 5

Thread: Percentage

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2002
    Posts
    56

    Percentage

    I'm sure this is pretty easy.....but i cant get round it

    The user enters a number in an imput box, this number is the percentage of a total size they want.

    For example, if the number entered was 10, and the total number was, say 350, alli would need to do is divide 350 by 10, getting 35. BUT......if the user inputs any other number, say 20, i wouldnt be able to divide by 20, instead i would need to divide by 5. See where i am coming from?

    Basicall, i think i am asking how can i find x% of a number???

    Is that what i am asking? i havent a clue lol

    Anyone?

    Thanks

    Dave

  2. #2
    Addicted Member Celest's Avatar
    Join Date
    Jun 2001
    Posts
    134
    100 / inputted number = number to divide by

    so, if they enter 20 then

    100 / 20 = 5

    The reason it works for 10 is because

    100 / 10 = 10

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2002
    Posts
    56
    Thanks, I knew it was an easy sum

    Dave

  4. #4
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    I would suggest you do:

    Percent/100*WholeVal

  5. #5
    Fanatic Member sql_lall's Avatar
    Join Date
    Jul 2002
    Location
    Up Above (i.e. AUS)
    Posts
    571

    Ok

    how can i find x% of a number???
    As Digi was saying, x% of a number=

    number * (x/100)

    i.e. 20% of 50=
    50 * (20/100)
    = 1000/100 = 10
    sql_lall

Posting Permissions

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



Click Here to Expand Forum to Full Width