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
|
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. |
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) |
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. |
This produced proper results -
Code:
GameTooltip:AddDoubleLine("Friendly Discount", addon:MoneyToString(floor(totalCost * 0.95), true)) |
Quote:
|
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 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% Code:
x = 100$*80%/100% |
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 Code:
80 x Code:
80 * 200 = 100 * x Code:
( 80 * 200 ) / 100 = 100x / 100 (I'm a math teacher.) |
Quote:
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. |
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. |
Quote:
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. |
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. ;)
|
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.
|
Quote:
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. |
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.
|
Actually Seerah's version is the same, just written down differently. It doesn't matter the calculation is the same.
Seerah Code:
percent portion Code:
whole portion |
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? |
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.
|
Well, using proportions is just one method of finding percents. The other way is this:
Code:
portion = whole * % |
Quote:
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 08:06 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI