Dear Ejs learning community

I have a question.

I have a custom function
double dv;
public String double2String(double v,double divider){
if(v > 0)dv=0.5;
else if(v < 0)dv=-0.5;
else dv=0;
return (int)(v*divider+dv)/divider+"";
}

the string called cannot display the values correctly
for example
s_E2 = " {g_net} = 6.67*10^{ - 11} *( " +double2String(m1,10.)+")"+"/("+double2String(x1-xtest,10.)+"){^2}" ;

how can the codes be modified to display in scientific form?

this doesn't work
s_E2 = " {g_net} = 6.67*10^{ - 11} *( " +double2String(m1,0.00E00)+")"+"/("+double2String(x1-xtest,0.00E00)+"){^2}" ;

any tips?

i think must rewrite the custom function but i don't know how to start  ;D
or is there some open source physics function that can do this?