Results 1 to 5 of 5
 01292012, 01:11 AM #1Member
 Join Date
 Jan 2012
 Posts
 3
 Rep Power
 0
not getting precision as expected
Per Ellipse CirumferenceHigh Accuracy from Polynomial
<script LANGUAGE="JavaScript">
function ec(form) {
X1=eval(form.A.value)
X2=eval(form.B.value)
HT1 = X2X1;
HB1 = X2+X1;
H1 = (Math.pow(HT1,2))/(Math.pow(HB1,2));
H2 = 43*H1;
C1 = Math.PI*HB1*(1+(3*H1)/(10+Math.pow(H2,0.5))+(5.1227200788995887836041683 376024e4)*Math.pow(H1,(0.3629877*Math.pow(H1,1024)0.80311737+Math.pow(H1,512)+1.7512218474*Math.pow( H1,256)1.734067037*Math.pow(H1,128)+2.957992923*Math.pow( H1,64)1.545484804*Math.pow(H1,32)+2.7559284083*Math.pow( H1,16)+0.176369301*Math.pow(H1,8)+2.95202242*Math. pow(H1,4)0.600612825*Math.pow(H1,2)+4.2106880013*H1+5.89029 54352)));
P = 9;
C1 = C1.toPrecision(P);
form.C.value = C1}
</SCRIPT>
<form>
When inputting numbers X1=1, X2=0.5 I am getting 4.84422412 when it should be 4.84422411. I did the calculations on a spreadsheet and verified 4.84422411 should be the correct answer. I changed the value of (4414*pi)/(11*pi) to the 5.122...e4 and even added more decimal places to the coefficients (that the truncated coefficients as listed on my web page were derived from) and still it does not help (this should not matter anyway but thought I would try).
I tried putting double declarations above and then deleted them when I was getting no response (perhaps I don't know how to properly do it).
Would someone copy the above into a program to troubleshoot the above and if somehow adding the double precision syntax or some other fashion to fix this, please show me how I should include into my program above.
Thanks!

Re: not getting precision as expected
What does this have to do with coding in the Java programming language?
 01292012, 01:13 AM #3Member
 Join Date
 Jan 2012
 Posts
 3
 Rep Power
 0
Re: not getting precision as expected
Note, there are no gaps in the numbers even though it is showing in the above window as such.
 01292012, 01:14 AM #4Member
 Join Date
 Jan 2012
 Posts
 3
 Rep Power
 0
Re: not getting precision as expected
Hmm, perhaps this part: "<script LANGUAGE="JavaScript">"

Re: not getting precision as expected
Similar Threads

Possible Loss of Precision?
By jwb4291 in forum New To JavaReplies: 6Last Post: 12022010, 04:28 AM 
Possible loss of precision
By jankidudel in forum New To JavaReplies: 2Last Post: 08072010, 10:15 AM 
possible loss of precision?
By gandalf5166 in forum New To JavaReplies: 6Last Post: 04132010, 08:21 PM 
Precision
By c_walker in forum New To JavaReplies: 1Last Post: 10182009, 11:36 AM 
Wrong precision
By lclclc in forum New To JavaReplies: 0Last Post: 09282009, 09:55 AM
Bookmarks