I need to round a result number,by precision;

Math : y=x/1000000; x=5 => y=0.000005,
but if I do this in java script y=0.00000500001;(not right) ;how do I round a equation by precision to have a math result

One way is that you can convert the result to a string object and do a substring to extract the portion of the result desired.

var a = 0.000050001;
var precision = 5;
var strA = a.toString();
var result = strA.substr(0, precision + 2);

I am not saying this is the only efficient way of doing it, but yes, one way of doing it.

Yes it is a option.
I have this code:

f = Math.pow((i+1),m)-1;
f /= den;
f *= document.calform.total_invested.value;
d = String(f).indexOf(".");
s = String(f).substring(0,(d+3));
document.calform.total.value = "$" + s;

the problem is if the document.calform.total_invested.value; is bigger then 100000000 the code is not working , it gives me
random results.

Look carefully the code I had posted and make the changes in your code accordingly. You are getting th formula and the method all wrong.