AFICS, print precision only affect floating number and have no effect on integer or extended integer.

*/1+i.10050 will overflow to double, but */1+i.10050x will not

max precision of ieee double is between 15 and 16 digits.
   10^.2^52
15.65356

Arie Groeneveld wrote:
It's because print precision is to 'low' .

  9!:11[6

  ts 'it=:|.&.":@(5{.":&(|.&.":))@*/1+i.10050'
|ill-formed number: ts
|   it=:    |.&.":@(5{.":&(|.&.":))@*/1+i.10050


Setting print precision to
  9!:11 [10

gives

  ts 'it=:|.&.":@(5{.":&(|.&.":))@*/1+i.10050'
0.141714 135040
  it
69696



=@@i



Geoff Canyon schreef:
I'm trying to find the last five non-zero digits of a large factorial. So for:

!10x = 3628800

the answer would be 36288 while for:

!20x = 2432902008176640000

the answer would be 17664.

I'm trying to do this by calculating /* 1+i.1000 without calculating large numbers by losing the trailing zeroes at each step and the leading digits more than five. Here's what I have so far:

(((|.&.":)@(5{.":&(|.&.":)))@*)/ 1+i.20x

The truncating code:

-- Converts to string, transposes, and converts back to a number. That loses trailing zeroes (because they're now leading zeroes). -- Converts to string and grabs the first five characters (which were the last five non-zero digits). -- Converts to string again -- not sure why this is necessary, but it doesn't work otherwise -- transposes, and converts back to a number.

This whole thing is performed atop *, and the resulting verb is inserted into the list from 1 to a large number.

This seems to work for large numbers up to 10049x. At 10050x I get an ill-formed number error.

Where did I go wrong?

regards,

Geoff
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to