I have this code: http://pastebin.com/Sd9WKZFr
When i call something like rate(60, -6000, 120000)
it returns me a NAN
result, but the same function on MS Excel returns me 0,04678...
. I have the same problem trying -5000, -4000, -3000 and -2000.
When i debug the code, i see that about the 8/9 iteration, the line number 29 begins to return a NAN
result, making all of other results to turn NAN
too.
BUT, when i call something like rate(60, -1000, 120000)
it returns me a float -0.02044...
, exactly the same result of MS Excel.
I have already tryed to convert all of math calculations into BCMath functions, but this way the results of -6000 is wrong (-1.0427... instead of 0,04678...) but using -1000 the result is correct, matching excel's result.
Is there a way to make it work correctly?
Thanks in advance for any useful sight about that.