For the extended precision facility to work properly, you have to start out with extended precision arguments and preserve the precision in the intermediate computations. So when you say %:2, that is a IEEE 64 bit float with only about 16 decimal digits of precision, and there is no way to manufacture more digits subsequently.
See the example in section II G of the dictionary http://www.jsoftware.com/help/dictionary/dictg.htm for the square root of 2. See http://www.jsoftware.com/jwiki/Essays/Extended%20Precision%20Functions for more general calculations. ----- Original Message ----- From: Nicholas Spies <[email protected]> Date: Wednesday, September 23, 2009 8:45 Subject: [Jprogramming] Accuracy question To: [email protected] > Solving question 80 in Project Euler, which asks for the sum of > the first > 100 digits of all irrational square roots from of the first 100 > decimal > digits, should > have been easy. > > I summed the first 100 digits of %:2 and got 442 instead > of the > expected 475. > This lead me to look at > > x: 1e30 * %: 2 > 1414213562373095 276779862491136 ...which do not match > 1414213562373095 04880.... > the first 21 digits of %:2 given in the problem. > > This lead me to check > > x: 1e30* 2^1r2 > 141421356237309 4995304885780480 ...which is broken where > it starts > to differ from the other two above. > > What should I be doing to get a good 100-digit approximation of > %:2 ? > > > Thanks, --Nick ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
