WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   Math Help (https://www.wowinterface.com/forums/showthread.php?t=42442)

Grimsin 01-24-12 11:23 AM

Math Help
 
I have a number, its a money value, I need to subtract 20% from it. how would you do that? then display the new number? since i cant use %'s

Xrystal 01-24-12 11:31 AM

20% is the same as 0.20 so multiply by 0.x for any percentage to get the percentage amount then deduct it from the original amount.


There is another way to get the result straight off but the above is the simplest method.

Dridzt 01-24-12 11:52 AM

money*0.8

All the money functions return copper amount.

So just use amount * 0.8 (that's 80%) then format it to gold silver copper with one of the built-in functions.

(can look it up, don't remember it off-hand)

Xrystal 01-24-12 12:30 PM

ah thats it ... result = ( money * ( 1 - (percent/100) )

if percent is 20 then this would come out as

(money * ( 1 - (20/100))
(money * ( 1 - 0.2))
(money * 0.8)

It would then work for any percentage you need.

Grimsin 01-24-12 12:51 PM

This produced proper results -
Code:

GameTooltip:AddDoubleLine("Friendly Discount", addon:MoneyToString(floor(totalCost * 0.95), true))
        GameTooltip:AddDoubleLine("Honored Discount", addon:MoneyToString(floor(totalCost * 0.9), true))
        GameTooltip:AddDoubleLine("Revered Discount", addon:MoneyToString(floor(totalCost * 0.85), true))
        GameTooltip:AddDoubleLine("Exaulted Discount", addon:MoneyToString(floor(totalCost * 0.8), true))


Phanx 01-25-12 12:40 AM

Quote:

Originally Posted by Xrystal (Post 251476)
20% is the same as 0.20 so multiply by 0.x for any percentage to get the percentage amount then deduct it from the original amount.

What kind of schools are people attending where they don't learn about percents? :(

zork 01-25-12 03:20 AM

One of the best things when it comes to percentages is the "Dreisatz" (rule of proportion).

http://en.wikipedia.org/wiki/Rule_of_proportion

So easy example. You have 100$. That is 100% of your money. You want so substract 20% of it. So you can write down:
Code:

100$    x
----  =  ---
100%    80%

x is the value you want to calculate and it is 100%-20% = 80% of your money.

Now all you have to do is to make the value for x come out. (Having x stand on one side)

To make that possible you multiplay both side of the equation with 80%. By doing that the 80% on the right side will fade because 80% / 80% is 1.

Code:

100$*80%      x*80%
--------  =  ---
100%          80%

100$*80%      x*1
--------  =  ---
100%          1

100$*80%     
--------  =  x
100%

Result:

Code:

x = 100$*80%/100%

x = 80$

The cool thing about that is that even the suffixes come out accordingly. The % delete themselve only the $ stays. Btw. 8000/100 is the same as 100*0.8. Doesn't matter.

Seerah 01-25-12 01:44 PM

I have never, ever seen that method using proportions before, Zork.

(At least in America) we teach that this is how to use proportions to solve percent problems.

Code:

percent    portion
--------- = ---------
  100        whole

so, let's say you want 80% of 200:
Code:

80      x 
----- = -----
 100    200

Then you cross-multiply
Code:

80 * 200 = 100 * x
divide by 100 on both sides to solve for x
Code:

( 80 * 200 ) / 100 = 100x / 100
160 = x


(I'm a math teacher.)

Ither 01-25-12 03:54 PM

Quote:

Originally Posted by Seerah (Post 251552)
I have never, ever seen that method using proportions before, Zork.

No disrespect, but that's because you're American?

Dreisatz is taught at realschulen (secondary school) in many European countries. I learned it and I live in Germany, well did until I moved to America.

Xrystal 01-25-12 05:52 PM

It's been a long while since I did basic maths in school in the UK but Seerah's way did look a lot more familar than Zorks. But then again things can change in 30 years rofl.

The way I mentioned was from my time as an accountancy software programmer. We had to use formulae like that all the time to get tax and discount calculations right.

Ither 01-25-12 06:00 PM

Quote:

Originally Posted by Xrystal (Post 251567)
It's been a long while since I did basic maths in school in the UK but Seerah's way did look a lot more familar than Zorks. But then again things can change in 30 years rofl.

That's because Dreisatz is not common in the UK--it's more common in Germany.

I'm 30 and I learned it through all school and have not seen it referenced in America. I came here for college in 2000.

Vlad 01-25-12 07:03 PM

I've seen solving for x like that, it's tbh even easier, and you solve for variables in higher level math too so it's nice to get used to. ;)

Seerah 01-25-12 08:47 PM

I'm sorry, I meant no disrespect when I said that. :o I guess that it's just that, to me, that seems very different (and almost wrong) than what we use. :) The math all works out, but when the proportions are set up that way it seems... as if the ratios are not set up correctly so to speak.

Ither 01-25-12 09:01 PM

Quote:

Originally Posted by Seerah (Post 251582)
I'm sorry, I meant no disrespect when I said that. :o I guess that it's just that, to me, that seems very different (and almost wrong) than what we use. :) The math all works out, but when the proportions are set up that way it seems... as if the ratios are not set up correctly so to speak.

Heh--and why Americans and Europeans don't always agree. ;)

I understand, I came here for college all the way up to Graduate (I have an MBA and a Masters in IT)--I had to learn some math all the way to Calculus and holy poodles did it make it hard. There were things I learned to do one way from Germany and others way American.

It's all fun though Seerah--I still love you. Can you help me with my fractions homework? Heheh.

suicidalkatt 01-25-12 10:50 PM

I prefer Seerah's method (but then again I was American method taught). It's much more straight forward. Cross multiplying just makes more sense once you understand the formulas behind it.

zork 01-26-12 08:04 AM

Actually Seerah's version is the same, just written down differently. It doesn't matter the calculation is the same.

Seerah
Code:

percent    portion
--------- = ---------
  100%      whole

Zork
Code:

  whole      portion
--------- = ---------
  100%      percent


kaels 01-26-12 11:44 AM

Yeah, they're mathematically equivalent :) I don't actually remember how I was taught t odo percents, but if I were to write it out, I'd probably do it Zork's way (I'm Canadian).

Seerah, I don't understand why you would teach kids to "cross-multiply" in that situation. Why multiply x by 100 just to divide it again?

SDPhantom 01-26-12 12:20 PM

People have their different ways, as long as it's all mathematically correct, the method doesn't really matter. I divide based on situation, finding an easy divisor and calculate the quantifier and use the formula, result=number / divisor * quantifier. Some percentages are easier than others, like 25% = 1/4, in which quantifier is 1 and divisor is 4. For 80%, the easy way would be using 8/10, but 3/5 would do too as it evaluates to the same number.

Seerah 01-26-12 05:29 PM

Well, using proportions is just one method of finding percents. The other way is this:
Code:

portion = whole * %
(where your percent is converted to a decimal by %/100.)

Ither 01-26-12 06:43 PM

Quote:

Originally Posted by Seerah (Post 251632)
Well, using proportions is just one method of finding percents. The other way is this:
Code:

portion = whole * %
(where your percent is converted to a decimal by %/100.)

You make this so difficult!

Here is my elite steps to subtracting/adding percentage.

1. pull out smart phone
2. slide finger to unlock
3. enter encryption code (I'm an IT nut)
4. slide finger left 2 times
5. select "calculator" app
6. enter first number
7. hit add/subtract as necessary
8. enter second number (the percentage add or removed)
9. hit % key
10. hit = key
11. laugh at the fact I did it in nanoseconds

OK, in all seriousness, our CPA at my office can literally do this in his head in second. I mess with him all the time "Hey bob, what's 20% off 1448.74" -- BAM answer. Of course I don't need it.


All times are GMT -6. The time now is 05:41 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI