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
https://forums.phpfreaks.com/topic/96672-stupid-maths-question/
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
https://forums.phpfreaks.com/topic/96672-stupid-maths-question/#findComment-494705
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
https://forums.phpfreaks.com/topic/96672-stupid-maths-question/#findComment-494708
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.