Jump to content

Stupid Maths Question


berridgeab

Recommended Posts

Hi

 

I have not really used the Math calculations in PHP however I have a really probably stupid question.

 

I have Two Variables: -

 

$Price = 20.40
$Discount = 45

 

How I work out the figure I need on a calculator is: -

 

Key in 20.40

Press Minus

Type in 45 and hit the % Sign

Works it out to: - 11.22

 

 

How would I do this in PHP, I know im doing something really stupid here but if I try and put the % sign in with any other calculation (i.e the minus sign) it causes PHP to error i.e.

 

$FinalCost = $Price - $Discount %;

 

Maybe I just need a brushup on my math.  ;D

 

 

Link to comment
Share on other sites

You have two variables which store a value in each,now what do you want to do with these values?

Do you want to divide,add,subtract or multiply or calculate the mode value,please specify clearly.

Mode:A%B=remainder or 0 if exactly divisible

Sub:A-B

Mul:A*B

Div:A/B and so on.

Link to comment
Share on other sites

Hi

 

Thank you for your reply, Basically what I want to do is Find 45% (Percent) of £20.40 which is £11.22.

 

I have finally figured it out however here is the forumla I use: -

 

Deduct Figure = Cost Price * Discount / 100

Final Figure = Cost Price - Deduct Figure

 

Or As in the example above: -

 

9.18 = 20.40 * 45 / 100

11.22 = 20.40 - 9.18

 

Thanks for your assistance anyway.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.