Next: , Previous: Floating-point Programming, Up: Arbitrary Precision Arithmetic


15.3 gawk + MPFR = Powerful Arithmetic

The rest of this chapter describes how to use the arbitrary precision (also known as multiple precision or infinite precision) numeric capabilities in gawk to produce maximally accurate results when you need it.

But first you should check if your version of gawk supports arbitrary precision arithmetic. The easiest way to find out is to look at the output of the following command:

     $ gawk --version
     -| GNU Awk 4.1.0, API: 1.0 (GNU MPFR 3.1.0-p3, GNU MP 5.0.2)
     -| Copyright (C) 1989, 1991-2013 Free Software Foundation.
     ...

gawk uses the GNU MPFR and GNU MP (GMP) libraries for arbitrary precision arithmetic on numbers. So if you do not see the names of these libraries in the output, then your version of gawk does not support arbitrary precision arithmetic.

Additionally, there are a few elements available in the PROCINFO array to provide information about the MPFR and GMP libraries. See Auto-set, for more information.