PARI/GP calculator, or gp for short, is an arbitrary-precision calculator (among other things) that I use frequently in my study of binary numbers. Here are instructions for installing and running it on Windows.
- Download the PARI/GP self-installing binary distribution for Windows.
As of this writing, the current stable version is Pari-2-3-4.exe. (There’s no need to download or install the optional packages — at least I don’t need them).
- Double click on the installer file to install (install all components).
You can set gp default settings by editing the gp customization file, “\PARI\.gprc”. For example, I have edited mine as follows:
- Changed the command prompt from the default timestamp format (prompt = "(%H:%M) gp > ") to ‘?’ (prompt = "? ").
- Added a line (format = "f") that makes all decimals print without scientific notation.
Here are some basic things you should know about running gp:
- Starting gp. Launch gp from the PARI folder under the Windows start menu.
- Setting variables. You can assign constants or results of calculations to variables; for example, n=8.
- Reusing prior calculations. The results of calculations are stored in a history array: %1 is the result of the first calculation, %2 is the result of the second calculation, etc. You can use these as variables in subsequent expressions.
- Changing the default precision. The default precision of printed decimal values is 28 significant digits; this can be changed with the ‘\p’ command. For example, ‘\p 50’ changes the print precision to 50 digits (PARI may set its internal precision higher than what you ask for; it must respect boundaries dictated by its implementation).
- Printing decimals instead of fractions. To force gp to print decimals instead of fractions, make sure a decimal point appears in the expression; for example, 2.^-2
- Executing previous commands. Previous commands can be accessed with the up arrow and down arrow keys.
- Copying and pasting. This is cumbersome, but can be done by right-clicking on the top of the command window and selecting ‘edit’. For copy, select ‘mark’, highlight the desired text in the command window and then hit enter. For paste, select ‘paste’.
- Logging your session. Type ‘\l’ to record your session — all commands and output — to the default PARI log file (\PARI\examples\pari.log). Type ‘\l’ again to stop recording.
- Exiting gp. Type ‘quit’ to exit gp.
See my article “Exploring Binary Numbers With PARI/GP Calculator” for example gp calculations.