Next: , Previous: , Up: Arbitrary Precision Arithmetic   [Contents][Index]

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.1, API: 1.1 (GNU MPFR 3.1.0-p3, GNU MP 5.0.2)
-| Copyright (C) 1989, 1991-2014 Free Software Foundation.

(You may see different version numbers than what’s shown here. That’s OK; what’s important is to see that GNU MPFR and GNU MP are listed in the output.)

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.