\[fun\] 500FTC BOUNTY - NOW CLAIMED! Not so simple, simple math...
-
[quote name=“Ruthie” post=“30538” timestamp=“1381090581”]
Great topic change…(ignoring the bits about average :o) now just remembering the laughs that David Mitchell gives me on Radio 4 and Peep Show :)
[/quote]Averages = Math = Original Topic. ; ;)
-
[quote name=“mnstrcck” post=“30539” timestamp=“1381090833”]
[quote author=Ruthie link=topic=3929.msg30538#msg30538 date=1381090581]
Great topic change…(ignoring the bits about average :o) now just remembering the laughs that David Mitchell gives me on Radio 4 and Peep Show :)
[/quote]Averages = Math = Original Topic. ; ;)
[/quote]I’ll go with that :)
-
[quote name=“spynappels” post=“30531” timestamp=“1381089153”]
[quote author=kris_davison link=topic=3929.msg30530#msg30530 date=1381088702]
Again im not sure this is right as 100 starting amount with a 1% fee in you calculation would end up something like what iawgoM had said.100 / 101 * 1 = 0.9900990099009901 ( and not 1 as it should be)
[/quote]I’m sorry, it should not be. The 1% is not of the starting amount but of the spend amount.
if the starting amount is 100FTC, the spendable amount is 99.00990099FTC (to 8 dec pl) and the fee is 1% of this, which when added together will add up to 100FTC (near as dammit)
So iawgo was right, I just got there in a slightly simpler way.
[/quote]Hmm good point but this now depends on if we are looking for 1% of the full amount deposited
as the fee or are we looking for 1% of the spend amount as the fee. Given that we only start with the full amount.If you simply divide by 100 plus the fee
then the higher the fee the more out the answer becomese.g
20% Fee
100 / 100% * 20 = 20
100 - 20 = 80
or
100 / 1.20 = 83.33333333333333
meaning the fee is only 16.6666 recurring of the total amountThe only way to get the correct answer is to fix the mistake in the original problem.
(I have added % signs to the simple int values that represent percentages)Example (ignoring any potential TX fee for now)
Fee = 1 [color=red][b] //just use 1 here instead of a decimal 0.01 (as it means 1% anyway)[/b][/color]
Balance = 100
100 * [color=red](Fee / 100%)[/color] = 1
100 - 1 = 99 (max spendable balance?) [b][color=red](This is Actually Correct!)[/color][/b]User then sends their displayed max spendable balance but the fee is charged on the amount entered, so…
>>> 99 * 0.01 = 0.99 [b][color=red](No dont do this)[/color][/b]
99 / (100% - Fee%) = 1 ()
99 + 1 = 100
100 - 100 = 0.00 (All is well again in the world :-) ) -
[quote name=“iawgoM” post=“30516” timestamp=“1381079477”]
Your problem here, because of which it’s impossible to make it “perfect” is limitation in number of decimal places. FTC client allows you only to send transactions with maximum of 8 decimal places.
Remember that movie when some guy thought of how banks kind of ignore small amounts beyond two decimal places? And he wrote a software that transfer all those leftovers to his own account? :) For example if someone’s balance with interests was 100.001 US$ in account you would always see 100.00. My BTC-e USD balance currently shows 0.00001009USD lol…In your case, maximum amount to spend if you have 100FTC and 1% fee would be: 99.00990099009900(990099…) - Excel and Windows calculators don’t even accept anything beyond 14
decimals (brackets).
Fee for this would be: 0.99009900990099. Total = 99.00990099009900 + 0.99009900990099 = 99.99999999999999So, you will have to find a way to calm down your OCD… :D
As I always copied the results from people in school, I’ve developed special skill - heavy improvisation to get this result, and my procedures probably made Newton and others scream in their graves ::) Teachers would always be like “dude, dafuq? what, this…how did you, why, how dare you, GTFO!!!” :D
But here it goes:
a (total amount) = 100.00 FTC
b (fee) = 0.01
c = 100*0.01 = 1
d = a - c = 100-1=99
e = d * 0.0001 = 99 * 0.0001 = 0.0099 (oh yes, adding 4 more decimal places)
f = e * 0.0001 = 0.0099 * 0.0001 = 0.00000099 (and 4 more - to get 8 decimal places total)
SPENDABLE=d+e+f = 99+0.0099+0.00000099 = 99.00990099
Fee for sendable amount = 99.00990099 * 0.01 = 0.9900990099 (notice the 10 decimal places here)
Spendable+fee = 99.9999999999 - and this cuts off after 8th decimal place?Let’s try with other number:
a (total amount) = 15.00 FTC
b (fee) = 0.01
c = 15*0.01 = 0.15
d = a - c = 15-0.15=14.85
e = d * 0.0001 = 14.85 * 0.0001 = 0.001485 (oh yes, adding 4 more decimal places)
f = e * 0.0001 = 0.001485 * 0.0001 = 0.00000014(85) (this one goes over 8 decimal places)
SPENDABLE=d+e+f = 14.85+0.001485+0.00000014 = 14.85148514
Fee for sendable amount = 14.85148514 * 0.01 = 0.1485148514 (notice the 10 decimal places here)
Spendable+fee = 14.99999999(14) - and this cuts off after 8th decimal place?This all means that people will still have some funds in their account…but they are beyond 8 decimal places…somewhere in limbo - but this way you will still show them what actually IS the maximum spendable amount.
Gosh, I’m so wrong with this, right? :D
[/quote]
[quote author=spynappels link=topic=3929.msg30529#msg30529 date=1381088316]
It’s actually probably a little easier still.The percentage fee is of the spend amount, so starting amount is 100% of spend amount plus fee percentage.
If fee is 1%, starting amount is 101% of spend amount.
Therefore spend amount = start amount / 1.01
Adjust the divisor depending on the fee percentage, for 5% spend amount = start amount / 1.05
[/quote]Just like to say thanks for everyone’s input. 8)
Ok I am going to accept, 2 answers, iawgoMs and spynappels, as they both solve my stated problem while retaining the accuracy that I require!
I will send iawgoM 400FTC for being the first and spynappels 100FTC for simplifying iawgoMs answer greatly! -
Thanks dude!
-
Hi,
a = 100 FTC
b = 1%–> c = 1 FTC (fee amount)
–> d = 99 FTC (spendable amount)Recalculation of the fee amount © from the perspective of the spendable amount (d)
= (d/(100-b)*100)/100*b = cWorks for every fee and amount.
-
[quote name=“Quer” post=“30586” timestamp=“1381152025”]
Hi,a = 100 FTC
b = 1%–> c = 1 FTC (fee amount)
–> d = 99 FTC (spendable amount)Recalculation of the fee amount © from the perspective of the spendable amount (d)
= (d/(100-b)*100)/100*b = cWorks for every fee and amount.
[/quote]Yes thats what I was trying to explain. But you can but try as they say!
-
[quote name=“kris_davison” post=“30602” timestamp=“1381160656”]
[quote author=Quer link=topic=3929.msg30586#msg30586 date=1381152025]
Hi,a = 100 FTC
b = 1%–> c = 1 FTC (fee amount)
–> d = 99 FTC (spendable amount)Recalculation of the fee amount © from the perspective of the spendable amount (d)
= (d/(100-b)*100)/100*b = cWorks for every fee and amount.
[/quote]Yes thats what I was trying to explain. But you can but try as they say!
[/quote]Your maths was impeccable, but UK Mark was trying to calculate (d) given (a) and (b), given that (b) was always going to be a percentage of (d).
iawgoM’s calculations calculated (d) to a sufficiently precise level.
You guys were right but focused on the fee amount rather than on the spendable amount.
-
True sufficiently accurate rather than accurate.
There was really no need to have rely on rounding at all. -
Sorry I’m happy you found a solution that fits that’s all that matters I guess. Just me being funny about maths the one area where a solution really can only be correct or not.
-
Well the operator just would make more money if the “full balance” is taken as 100% and the fee applies for the total amount, rather than taking the spendable amount as 100%. When it’s an external fee for the transaction he would even pay extra (the higher the amount and the fee percentage, the worse it gets). Also its way clearer for the customer to follow a simple percentage calculation ;)
Just my opinion. :P
Cheers.
-
[quote name=“kris_davison” post=“30619” timestamp=“1381169714”]
Sorry I’m happy you found a solution that fits that’s all that matters I guess. Just me being funny about maths the one area where a solution really can only be correct or not.
[/quote]
[quote author=Quer link=topic=3929.msg30736#msg30736 date=1381277656]
Well the operator just would make more money if the “full balance” is taken as 100% and the fee applies for the total amount, rather than taking the spendable amount as 100%. When it’s an external fee for the transaction he would even pay extra (the higher the amount and the fee percentage, the worse it gets). Also its way clearer for the customer to follow a simple percentage calculation ;)Just my opinion. :P
Cheers.
[/quote]Thanks for your input guys, unfortunately your answers did not solve my problem as [i]stated[/i].
Both iawgoMs and spynappels did as they had the benefit of also enabling me to show the [i]exact[/i] fee charged on the maximum spendable amount down to 8dp.