T=:10000000000000306999999999997669x 9!:11 ]20 NB. print precision
T^0.5 3162277660168428 T^0.5 appears to be integer and so <. leaves it unchanged T<....@^0.5 3162277660168427 Special code http://www.jsoftware.com/help/dictionary/special.htm : <....@f both also >....@f ; avoids non-integer intermediate results on extended precision integers 41 43 47 53| */p:i.16 0 0 0 0 R.E. Boss -----Oorspronkelijk bericht----- Van: [email protected] [mailto:[email protected]] Namens Gerry J Verzonden: dinsdag 19 januari 2010 8:22 Aan: Programming forum Onderwerp: [Jprogramming] difficulty with extended precision arithmetic Hello, although i programmed APL for a few years a long time ago, i am new to J. I am trying to perform extended precision integer arithmetic. T, a global has been assigned this value 10000000000000306999999999997669x Then i perform this x=:x:<.T^0.5 x 3162277660168428 The correct square root from another source is 3162277660168427.8729609771283143493714513369669538 so i would expect to get 316227766016842* 7* as the floor, not 316227766016842 *8* from the result obtained, (3162277660168428)^2 is more than T, so it would appear not to be the correct floor of square root of T. How should i code to get 3162277660168427 for <.T^0.5? (apart from subtracting 1 :-) ) I also computed */ for all primes up to 41 then up to 53 and tried to get the residue of the result for each of the primes involved. I expected to get zeroes, but for the cases ending at 53 i was getting some non zero. DP=:80, is there some other configuration variable that is relevant or do i need to code these differently? -- Regards, Gerry J ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
