Thread Tools Display Modes
01-26-12, 08:48 PM   #21
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
Originally Posted by TheGeek View Post
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
I just type something like this in WoW.
Code:
/dump 12*0.3
Faster than finding your phone and doing all that.
... and I'm usually in WoW anyway.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 01-26-12 at 08:52 PM.
  Reply With Quote
01-26-12, 11:45 PM   #22
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Originally Posted by TheGeek View Post
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.
Oh sure. You take 10% and then multiply it by 2.

10% of 1448.74 is (rounded) 145, times 2 is 290.


/edit: shh! don't tell him I told you his secret!
__________________
"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

  Reply With Quote
01-27-12, 02:50 AM   #23
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
Originally Posted by Seerah View Post
Originally Posted by TheGeek View Post
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.
Oh sure. You take 10% and then multiply it by 2.

10% of 1448.74 is (rounded) 145, times 2 is 290.


/edit: shh! don't tell him I told you his secret!
20% *off* 1448.74 would be 80%, which would change to formula to:

1448.74 / 10 = 144.874
144.874 * 8 = 1158.992

It's a little harder calculation but us programmers are known for taking shortcuts anyway.
Then again, I can come up with an answer from my head in a split second too, nobody said it had to be right.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
01-27-12, 03:52 AM   #24
unlimit
Lookin' Good
 
unlimit's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 484
Originally Posted by SDPhantom View Post
20% *off* 1448.74 would be 80%, which would change to formula to:

1448.74 / 10 = 144.874
144.874 * 8 = 1158.992

It's a little harder calculation but us programmers are known for taking shortcuts anyway. :p
Then again, I can come up with an answer from my head in a split second too, nobody said it had to be right. :D
x * 0.1 * 8 = y

:D?

?????

D:
__________________


kúdan: im playing pantheon
JRCapablanca: no youre not
** Pantheon has been Banned. **
  Reply With Quote
01-27-12, 08:40 AM   #25
Ither
A Firelord
 
Ither's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2009
Posts: 497
Originally Posted by Seerah View Post
Oh sure. You take 10% and then multiply it by 2.

10% of 1448.74 is (rounded) 145, times 2 is 290.


/edit: shh! don't tell him I told you his secret!
Oh he's tried to teach me but I am not that fast. I'm smart, but not numbers smart LOL.
__________________
  Reply With Quote
01-27-12, 09:17 AM   #26
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
You can Google 100-20%
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
01-27-12, 09:19 AM   #27
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
Windows Calculator BSoD'ed on the second decimal, so I had to resort to googling it, but it autocorrected into doing a barrel roll, so I ultimately asked WolframAlpha

Last edited by Ketho : 01-27-12 at 09:24 AM.
  Reply With Quote
01-27-12, 09:35 AM   #28
Ither
A Firelord
 
Ither's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2009
Posts: 497
Originally Posted by zork View Post
You can Google 100-20%
There is a lot of things Google can answer, except why I have no girlfriend.

I thought American wommens liked Europeans.
__________________
  Reply With Quote
01-27-12, 10:36 AM   #29
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Originally Posted by SDPhantom View Post
20% *off* 1448.74 would be 80%, which would change to formula to:

1448.74 / 10 = 144.874
144.874 * 8 = 1158.992

It's a little harder calculation but us programmers are known for taking shortcuts anyway.
Then again, I can come up with an answer from my head in a split second too, nobody said it had to be right.
Bah, I missed that second f.
__________________
"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

  Reply With Quote
01-27-12, 11:47 AM   #30
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
Regardless of what method i use there is an issue with the code... when you floor the math for the cost of the repair the calculations for the faction discounts become off by up to 2 copper... or at least ive seen it up to 2copper its off by one copper most of the time. Any thoughts? My initial thought is to ditch the floor math and create my own flooring function thats a bit more accurate but... if i remove floor it of course displays accurate amounts but has the really long decimal. maybe ditch the floor and add a string sub to remove the decimal and anything after it?

edit -- grr to do the string edit it think i would have to edit my money to string...
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]

Last edited by Grimsin : 01-27-12 at 11:51 AM.
  Reply With Quote
01-27-12, 12:25 PM   #31
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
Originally Posted by Seerah View Post
Bah, I missed that second f.
We still love you.



Originally Posted by Grimsin View Post
Regardless of what method i use there is an issue with the code... when you floor the math for the cost of the repair the calculations for the faction discounts become off by up to 2 copper... or at least ive seen it up to 2copper its off by one copper most of the time.
Blizz could be rounding it, in which the formula for rounding is:
Code:
x=math.floor(y+0.5);

Either that or they could be using math.ceil() which shifts the number up to the nearest integer instead of just dropping the decimal. This is actually used most in PoS (Point of Sale) programs where fractional cents in line totals are always rounded up. This is to cover the suggested price of an item while erring on the side of being over instead of short money.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 01-27-12 at 12:37 PM.
  Reply With Quote
01-27-12, 12:38 PM   #32
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
hmm good point. i will have to study it some more and see if i using math.ciel works. and what dif does using floor vs math.floor make?
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
01-27-12, 01:13 PM   #33
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
floor is Blizzard's shortcut to math.floor
http://wowprogramming.com/docs/api/floor
__________________
"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

  Reply With Quote
01-27-12, 01:43 PM   #34
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
I need to just drop the decimal instead of round either direction
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
01-27-12, 02:49 PM   #35
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
That is what math.floor does.
__________________
"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

  Reply With Quote
01-27-12, 03:48 PM   #36
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
Originally Posted by Seerah View Post
That is what math.floor does.
Doesnt flooring cause it to round down?

Hmm and lets say it does not... somethings wrong somewhere because my end result is always off by a copper...
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]

Last edited by Grimsin : 01-27-12 at 03:54 PM.
  Reply With Quote
01-27-12, 03:56 PM   #37
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
the code for the function to get durability as well as the tooltip function thats supposed to display the repair cost...
Code:
-- Durability Frame --
local equipCost = 0;
local bagCost = 0;
local totalCost = 0;
local pEquipDura = { min=0, max=0};
local pBagDura = { min=0, max=0};
local slots = { "HeadSlot", "ShoulderSlot", "ChestSlot", "WaistSlot", "WristSlot", "HandsSlot", "LegsSlot", "FeetSlot", "MainHandSlot", "SecondaryHandSlot", "RangedSlot" }
slots[0] = 'AmmoSlot'
local myTip = nil
function GUI_DashDurability:GetDurabilityInfo()
	pEquipDura = { min=0, max=0};
	pBagDura = { min=0, max=0};
	if not tmpTip then tmpTip = CreateFrame("GameTooltip", "GUITT") end
	equipCost = 0
	for _, slotName in ipairs(slots) do
		local item = _G["Character" .. slotName]
		local hasItem, _, repairCost = tmpTip:SetInventoryItem("player", item:GetID())
		local Minimum, Maximum = GetInventoryItemDurability(item:GetID())
		if hasItem and repairCost and repairCost > 0 then
			equipCost = equipCost + repairCost
		end
		if Minimum and Maximum then
			pEquipDura.min = pEquipDura.min + Minimum
			pEquipDura.max = pEquipDura.max + Maximum
		end
	end
	bagCost = 0
	for bag = 0, 4 do
		for slot = 1, GetContainerNumSlots(bag) do
			local hasCooldown, repairCost = tmpTip:SetBagItem(bag, slot)
			local Minimum, Maximum = GetContainerItemDurability(bag, slot)
			if repairCost and repairCost > 0 then
				bagCost = bagCost + repairCost
			end
			if Minimum and Maximum then
				pBagDura.min = pBagDura.min + Minimum
				pBagDura.max = pBagDura.max + Maximum
			end
		end
	end
	if bagCost < 0 then bagCost = 0 end
	totalCost = equipCost + bagCost
end
local function GUI_DashDurability_OnEnter(self)
	if not myTip then
		myTip = CreateFrame('GameTooltip')
		myTip:Hide()
	end
	local cP = (pEquipDura.max > 0 and floor(pEquipDura.min / pEquipDura.max * 100)) or 100
	local bP = (pBagDura.max > 0 and floor(pBagDura.min / pBagDura.max * 100)) or 100
	local tP = ((pEquipDura.max + pBagDura.max) > 0 and floor( (pEquipDura.min + pBagDura.min) / (pEquipDura.max + pBagDura.max) * 100)) or 100
	if cP > 100 then cP = 100 end
	if bP > 100 then bP = 100 end
	if tP > 100 then tP = 100 end
	GUI_ToolTipSetup(self)
	GameTooltip:AddLine(_G['REPAIR_COST'])
	GameTooltip:AddLine(" ")
	GameTooltip:AddDoubleLine(_G['CURRENTLY_EQUIPPED'].." ("..addon:DurColor(cP)..cP.."%|r".."):", addon:MoneyToString(equipCost, true))
	GameTooltip:AddDoubleLine("Inventory".." ("..addon:DurColor(bP)..bP.."%|r".."):", addon:MoneyToString(bagCost, true))
	GameTooltip:AddLine(" ")
	GameTooltip:AddDoubleLine(_G['REPAIR_ALL_ITEMS'].." ("..addon:DurColor(tP)..tP.."%|r".."):", addon:MoneyToString(totalCost, true))
	GameTooltip:AddDoubleLine("Friendly Discount", addon:MoneyToString(math.floor(totalCost * 0.95), true))
	GameTooltip:AddDoubleLine("Honored Discount", addon:MoneyToString(math.floor(totalCost * 0.9), true))
	GameTooltip:AddDoubleLine("Revered Discount", addon:MoneyToString(math.floor(totalCost * 0.85), true))
	GameTooltip:AddDoubleLine("Exaulted Discount", addon:MoneyToString(math.floor(totalCost * 0.8), true))
	GameTooltip:AddLine(" ")
	GameTooltip:AddLine("|cffeda55fLeft Click|r toggle Auto-Repair  " .. (addon.settings.autoRepair and "|cff88ff88on|r" or "|cffff8888off|r"), 0.2, 1, 0.2)
	GameTooltip:AddLine("|cffeda55fRight Click|r toggle Guild Funds  " .. (addon.settings.GuildRepair and "|cff88ff88on|r" or "|cffff8888off|r"), 0.2, 1, 0.2)
	GameTooltip:Show()
end
GUI_DashDurability:SetScript('OnEnter', GUI_DashDurability_OnEnter)
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
01-27-12, 05:15 PM   #38
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
I could be wrong, but I don't think faction discounts are applied to repairs.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
01-27-12, 05:16 PM   #39
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
I think they are. I remember hating having to repair at a Jeeves because repairing at Stormwind was much cheaper.
  Reply With Quote
01-27-12, 05:21 PM   #40
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
they are...

cut and paste from wowwikki --

The reputation discounts are taken from the prices above as follows: 5% for friendly, 10% for honored, 15% for revered and 20% for exalted.
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]

Last edited by Grimsin : 01-27-12 at 05:30 PM.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Math Help

Thread Tools
Display Modes

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