Math Help - WoWInterface
01-24-12, 11:23 AM   #1
Grimsin
A Molten Giant

Join Date: Sep 2006
Posts: 990
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
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]

01-24-12, 11:31 AM   #2
Xrystal
nUI Maintainer

Join Date: Feb 2006
Posts: 5,178
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.
__________________

01-24-12, 11:52 AM   #3
Dridzt
A Pyroguard Emberseer

Join Date: Nov 2005
Posts: 1,251
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)

01-24-12, 12:30 PM   #4
Xrystal
nUI Maintainer

Join Date: Feb 2006
Posts: 5,178
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.
__________________

01-24-12, 12:51 PM   #5
Grimsin
A Molten Giant

Join Date: Sep 2006
Posts: 990
This produced proper results -
Code:
```GameTooltip:AddDoubleLine("Friendly Discount", addon:MoneyToString(floor(totalCost * 0.95), true))
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]

01-25-12, 12:40 AM   #6
Phanx
Cat.

Join Date: Mar 2006
Posts: 5,617
 Originally Posted by Xrystal 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?

01-25-12, 03:20 AM   #7
zork
A Pyroguard Emberseer

Join Date: Jul 2008
Posts: 1,706
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.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW) | TDMOG

 "I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 01-25-12 at 03:36 AM.

01-25-12, 01:44 PM   #8
Seerah
Fishing Trainer

Join Date: Oct 2006
Posts: 10,527
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.)
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

01-25-12, 03:54 PM   #9
Ither
A Firelord

Join Date: Apr 2009
Posts: 496
 Originally Posted by Seerah 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.
__________________

01-25-12, 05:52 PM   #10
Xrystal
nUI Maintainer

Join Date: Feb 2006
Posts: 5,178
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.
__________________

01-25-12, 06:00 PM   #11
Ither
A Firelord

Join Date: Apr 2009
Posts: 496
 Originally Posted by Xrystal 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.
__________________

01-25-12, 07:03 PM   #12
A Molten Giant

Join Date: Dec 2005
Posts: 789
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.

01-25-12, 08:47 PM   #13
Seerah
Fishing Trainer

Join Date: Oct 2006
Posts: 10,527
I'm sorry, I meant no disrespect when I said that. 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.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

01-25-12, 09:01 PM   #14
Ither
A Firelord

Join Date: Apr 2009
Posts: 496
 Originally Posted by Seerah I'm sorry, I meant no disrespect when I said that. 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.
__________________

01-25-12, 10:50 PM   #15
suicidalkatt
A Rage Talon Dragon Guard

Join Date: Mar 2008
Posts: 329
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.

01-26-12, 08:04 AM   #16
zork
A Pyroguard Emberseer

Join Date: Jul 2008
Posts: 1,706
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```
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW) | TDMOG

 "I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 01-26-12 at 08:09 AM.

01-26-12, 11:44 AM   #17
kaels
A Cyclonian
Join Date: Jan 2011
Posts: 46
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?

01-26-12, 12:20 PM   #18
SDPhantom
A Pyroguard Emberseer

Join Date: Jul 2006
Posts: 1,732
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.
__________________
 "All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools." -Anders (Dragon Age: Origins - Awakening)

01-26-12, 05:29 PM   #19
Seerah
Fishing Trainer

Join Date: Oct 2006
Posts: 10,527
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'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

01-26-12, 06:43 PM   #20
Ither
A Firelord

Join Date: Apr 2009
Posts: 496
 Originally Posted by Seerah 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
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.
__________________

 WoWInterface » Math Help

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts vB code is On Smilies are On [IMG] code is On HTML code is Off