Percent Calc Problem

There is no "special" handling for negative numbers. Because all these elementary calculations work just fine with any real number (positive or negative).
Hmm. not true, IMO. Proof:

This gives a wrong result ec when sc is negative:
sc=-200; pp=10.668192; n=4; ec = sc * pow(1 + pp / 100, n) ; ec
-300.00000032494801157600

But when used with a positive sc it suddenly gives a correct result:
sc=100; pp=10.668192; n=4; ec = sc * pow(1 + pp / 100, n) ; ec
150.00000016247400578800

sc is startcap, ec is endcap. The pp (ie. periodpercent) is from your previous example; it gives 50% after 4 periods (ie. n=4 above) [ie. after subtracting the initial 100%].
As you can see: using a negative value does not work (gives wrong result), and sometimes even impossible to calculate b/c logarithm of a negative value is mathematically undefined (that variant of the above formula is used when solving it for n).

Btw, the above code is from the "bc" calculator under Linux.
 
Last edited:
Hmm. not true, IMO. Proof:

This gives a wrong result ec when sc is negative:
sc=-200; pp=10.668192; n=4; ec = sc * pow(1 + pp / 100, n) ; ec
-300.00000032494801157600

But when used with a positive sc it suddenly gives a correct result:
sc=100; pp=10.668192; n=4; ec = sc * pow(1 + pp / 100, n) ; ec
150.00000016247400578800

sc is startcap, ec is endcap. The pp (ie. periodpercent) is from your previous example; it gives 50% after 4 periods (ie. n=4 above) [ie. after subtracting the initial 100%].
As you can see: using a negative value does not work (gives wrong result), and sometimes even impossible to calculate b/c logarithm of a negative value is mathematically undefined (that variant of the above formula is used when solving it for n).

Btw, the above code is from the "bc" calculator under Linux.

First of all, use the same (in absolute value) starting point sc, otherwise, you won't be able to compare and understand what is going on. When debugging, the first rule is to make one change at a time. (I would advise you to use more meaningful names for your variables and round the printout to 2 decimal digits :) )

Second, why do you think the first result is wrong?

(hint: have you noticed the negative interest in my previous table to "reduce debt" ?)
 
First of all, use the same (in absolute value) starting point sc, otherwise, you won't be able to compare and understand what is going on. When debugging, the first rule is to make one change at a time. (I would advise you to use more meaningful names for your variables and round the printout to 2 decimal digits :) )
A dumb advise to a professional :)These are default settings of the calculator. It's just an external tool.
Second, why do you think the first result is wrong?
(hint: have you noticed the negative interest in my previous table to "reduce debt" ?)
B/c when PnL is positive (-200 to -100 means +100 profit), then consequently the PnL% has to be positive as well. Q.E.D. :)
Such folks like you are just some hot-air talkers, nothing more.
 
Last edited:
Hmm. not true, IMO. Proof:

This gives a wrong result ec when sc is negative:
sc=-200; pp=10.668192; n=4; ec = sc * pow(1 + pp / 100, n) ; ec
-300.00000032494801157600

As you can see: using a negative value does not work (gives wrong result)

Dear earth_imperator,

I cannot see any wrong results in the output. All I can see, instead, is that the line of code:

ec = sc * pow(1 + pp / 100, n) ;

makes no sense whatsoever in your context.

What do you think to achieve plugging a relative change into the formula for periodic interest? Which, further, in this case, is still wrong, as requires a negative interest with negative values?

This is similar to computing the fall of bodies using the formula for uniform motion and also getting the wrong sign for the velocity vector.


> A dumb advise to a professional
> Such folks like you are just some hot-air talkers, nothing more.


btw, before I respond to your ungrammatical insults towards a person helping you, are you an adult or a kid?
 
Last edited:
There is no "special" handling for negative numbers. Because all these elementary calculations work just fine with any real number (positive or negative).

One has just to understand and use the correct "general" formulas (not the "reduced" special case, valid for positive numbers only, that were sketched in some of the posts above). These are all on Wikipedia.

Note, in particular, that the use of abs() or the sign() function is missing in the posts above. Also, this is quite basic stuff. One has no real need for pre-made libraries.

The arithmetic involved is the same as positive numbers (just the sign is reversed). Like (-1) - (-2) = 1 and (1) - (2) = -1.

my suggestion was actually more akin to a thought experiment

In case of doubts, one could simply take the function as a black box process (hence the need to have it from a reputable source), plug in a few positive and negative numbers, and confirm the correct application of the formula by looking at the output.

I'm no quant, but I suppose that there are libraries available for any major language with all the basic financial functions. Heck, we are talking about the formula for calculating percent returns, not about an obscure stochastic volatility model..
 
I have negative interest ... in this topic.

I'll be gone now, but not before asking where can I get one of those negative start capital trading accounts? :confused: I've got -$10,000 burning a hole in my pocket.
 
I have negative interest ... in this topic.

I'll be gone now, but not before asking where can I get one of those negative start capital trading accounts? :confused: I've got -$10,000 burning a hole in my pocket.

in that case, you might also try an imaginary one :)

 
I have negative interest ... in this topic.

I'll be gone now, but not before asking where can I get one of those negative start capital trading accounts? :confused: I've got -$10,000 burning a hole in my pocket.
It's the value of an account deep in the reds, sometimes later, not in the beginning.
It happens with short positions. As everybody should now: when shorting then even more than 100% loss is possible (ie. mathematically even < than -100%).
Still, the account has to be calculated about its daily changes (absolute as well relative daily change). It's primarily about this task. But one can use it also for some more advanced calculations (portfolio calcs and margin calcs)
 
Last edited:
my suggestion was actually more akin to a thought experiment
...


Do this simple "experiment". Use the formula improperly used by the OP:

ec = sc * pow(1 + pp / 100, n) ;

and run with the following settings:

sc = 200 or sc=-200
and pp = -15.91

do it for n= 0,1,2,3,4.
 
Back
Top