A simple exampel: !23 2.5852e22 x:!23 25852016738884978212864 !23x 25852016738884976640000
--- Den ons 20/1/10 skrev Joey K Tuttle <[email protected]>: Fra: Joey K Tuttle <[email protected]> Emne: Re: [Jprogramming] difficulty with extended precision arithmetic Til: "Programming forum" <[email protected]> Cc: "Programming forum" <[email protected]> Dato: onsdag 20. januar 2010 05.47 Also, you should note that if you "start off" with extended integers things work ok - e.g. */ ~. 4 p: i. 53x 32589158477190044730 At 11:05 +1100 2010/01/20, Gerry J wrote: >Thanks very much to those who responded. >It seems that most of the difficulty i had was traceable to x: not >forcing the equivalent of the sqrt function before floor was applied. >I was mainly interested in getting the correct floor but the other >information and directions are most useful. >I clearly have a lot of catching up to do. >As regards the second area "the product of primes" i found that it was >necessary to use x: at the very beginning, so that problem is overcome. >In case my misunderstanding is helpful to others... > >NB. it appears that "ordinary" integers need to be processed with x: in >some cases >NB. or else a later calculation may not be in ep mode >NB. "ep" == extended precision > > >NB. This case doesn't tag the output as exact integers for later >calculation, ie extended precision isn't forced in respect of earlier >variables simply by using x: in later calculations > pns=: ~.4 p:i.53 > pns >2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 >NB. i had expected if x: was used in the following statement that ep >would be forced for all inputs >NB. maybe a "nice to have"? > pp=:x:*/pns > pp >32589158477190045696 NB. incorrect because input has 2*5 the >result has to end in 0 > x:pns|pp >0 0 1 0 9 4 14 16 0 9 5 4 23 20 26 12 > NB. oops the ordinary integers in */pns though just plain integers >don't produce a correct result for pp just because x: is used in the >statement > NB. Now tag the first calculation with x: > pns=:x: ~.4 p:i.53 > pns >2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 > NB. looks the same, but treated differently > pp=:x:*/pns > pp >32589158477190044730 NB. correct > NB. and gives different and correct result below > x:pns|pp >0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 NB. what i needed, but also > pns|pp NB. didn't need the x: >there; ... it is just pns that needed to be set up "right" >0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 > > >Thanks again for the earlier advice. > >-- >Regards, >Gerry Jensen >02 9713 6004 ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ___________________________________________________________ Skal du købe ny bil? Sammenlign priser på brugte biler med Kelkoo og find et godt tilbud! - Se mere her http://dk.yahoo.com/r/pat/mmb ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
