How to take off a percentage?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • adamjblakey
    New Member
    • Jan 2008
    • 133

    #1

    How to take off a percentage?

    Hi,

    I have the following values:

    49.99
    99.99
    149.99
    199.99

    People can enter a coupon code to take away e.g. 10, 20, 30%

    How would i take away one of the above percentages away from e.g. 199.99

    Cheers,
    Adam
  • hsriat
    Recognized Expert Top Contributor
    • Jan 2008
    • 1653

    #2
    Originally posted by adamjblakey
    Hi,

    I have the following values:

    49.99
    99.99
    149.99
    199.99

    People can enter a coupon code to take away e.g. 10, 20, 30%

    How would i take away one of the above percentages away from e.g. 199.99

    Cheers,
    Adam
    10% of 199.99 = 199.99*(10/100) = 19.999

    Are you asking this or something else?

    Comment

    • adamjblakey
      New Member
      • Jan 2008
      • 133

      #3
      Originally posted by hsriat
      10% of 199.99 = 199.99*(10/100) = 19.999

      Are you asking this or something else?

      Yes thanks but what i need it to is e.g.

      If i do this

      $total = 199.99;
      $maintotal = $total*(50/100);

      Then i get back 75 but what i need back is 74.99

      Any ideas?

      Comment

      • hsriat
        Recognized Expert Top Contributor
        • Jan 2008
        • 1653

        #4
        Originally posted by adamjblakey
        Yes thanks but what i need it to is e.g.

        If i do this

        $total = 199.99;
        $maintotal = $total*(50/100);

        Then i get back 75 but what i need back is 74.99

        Any ideas?
        I think there's something wrong with server that it gives 75 when you process the above said equation.

        A function known as round() is used, but to convert 74.99 to 75, not the other way.

        You may tell more detail about the problem, then I can help you.

        Comment

        • ronverdonk
          Recognized Expert Specialist
          • Jul 2006
          • 4259

          #5
          There is definitely something wrong. The following results 99.995[php]<?php
          echo 199.99*(50/100);
          //result = 99.995
          ?>[/php]Ronald

          Comment

          Working...