Search code examples
pari

Copying numbers from PARI/GP


I have a problem, for which there probably is an easy solution.

Suppose, I have calculated a large number in PARI/GP, lets say, 10,000 digits long.

I want to copy this number in a normal text file, such that it can be copied back to PARI/GP.

The problem is, that the program does not avoid (hidden) new-line-marks, so if I copy the number back, it cannot be read by PARI. The print1-command does not help either.

I had two non-satisfactionary ideas :

1) Copying in an editor, using the backspace-key to remove the (hidden) new-line-marks, which only works upto some length.

2) Extending the allowed length of a line, but then I cannot easily and fast mark the number, which is no problem with the normal lentgh 80.

How can I avoid the new-line-marks in the output in PARI/GP ?


Solution

  • Piotr already gave the answer in a comment. Suppose you have:

    n = 1<<33216
    

    or any other number. Then if you use:

    write("MySavedNumber.txt", n)
    

    things will be fine. No new-lines in the middle of the text file.

    When you need to recover the number in another session of PARI/GP, simply use:

    n = read("MySavedNumber.txt")