diff options
Diffstat (limited to 'doc/gawk.info')
-rw-r--r-- | doc/gawk.info | 1947 |
1 files changed, 1393 insertions, 554 deletions
diff --git a/doc/gawk.info b/doc/gawk.info index ca6b661f..bf279828 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -89,6 +89,8 @@ texts being (a) (see below), and with the Back-Cover Texts being (b) * Functions:: Built-in and user-defined functions. * Internationalization:: Getting `gawk' to speak your language. +* Arbitrary Precision Arithmetic:: Arbitrary precision arithmetic with + `gawk'. * Advanced Features:: Stuff for advanced users, specific to `gawk'. * Library Functions:: A Library of `awk' Functions. @@ -354,6 +356,21 @@ texts being (a) (see below), and with the Back-Cover Texts being (b) * I18N Portability:: `awk'-level portability issues. * I18N Example:: A simple i18n example. * Gawk I18N:: `gawk' is also internationalized. +* Floating-point Programming:: Effective floating-point programming. +* Floating-point Representation:: Binary floating-point representation. +* Floating-point Context:: Floating-point context. +* Rounding Mode:: Floating-point rounding mode. +* Arbitrary Precision Floats:: Arbitrary precision floating-point + arithmetic with `gawk'. +* Setting Precision:: Setting the working precision. +* Setting Rounding Mode:: Setting the rounding mode. +* Floating-point Constants:: Representing floating-point constants. +* Changing Precision:: Changing the precision of a number. +* Exact Arithmetic:: Exact arithmetic with floating-point numbers. +* Integer Programming:: Effective integer programming. +* Arbitrary Precision Integers:: Arbitrary precision integer + arithmetic with `gawk'. +* MPFR and GMP Libraries:: Information about the MPFR and GMP libraries. * Nondecimal Data:: Allowing nondecimal input data. * Array Sorting:: Facilities for controlling array traversal and sorting arrays. @@ -1102,10 +1119,12 @@ it is today. It has been and continues to be a pleasure working with this team of fine people. John Haque contributed the modifications to convert `gawk' into a -byte-code interpreter, including the debugger. Stephen Davies -contributed to the effort to bring the byte-code changes into the -mainstream code base. Efraim Yawitz contributed the initial text of -*note Debugger::. +byte-code interpreter, including the debugger, and the additional +modifications for support of arbitrary precision arithmetic. Stephen +Davies contributed to the effort to bring the byte-code changes into +the mainstream code base. Efraim Yawitz contributed the initial text +of *note Debugger::. John Haque contributed the initial text of *note +Arbitrary Precision Arithmetic::. I would like to thank Brian Kernighan for invaluable assistance during the testing and debugging of `gawk', and for ongoing help and @@ -2295,6 +2314,12 @@ The following list describes options mandated by the POSIX standard: inappropriate construct. As `awk' programs are usually short, doing so is not burdensome. +`-M' +`--bignum' + Force arbitrary precision arithmetic on numbers. This option has + no effect if `gawk' is not compiled to use the GNU MPFR and MP + libraries (*note Arbitrary Precision Arithmetic::). + `-n' `--non-decimal-data' Enable automatic interpretation of octal and hexadecimal values in @@ -9303,6 +9328,15 @@ specific to `gawk' are marked with a pound sign (`#'). every `print' statement. Its default value is `"\n"', the newline character. (*Note Output Separators::.) +`PREC #' + The working precision of arbitrary precision floating-point + numbers, 53 by default (*note Setting Precision::). + +`ROUNDMODE #' + The rounding mode to use for arbitrary precision arithmetic on + numbers, by default `"N"' (`roundTiesToEven' in the IEEE-754 + standard) (*note Setting Rounding Mode::). + `RS' This is `awk''s input record separator. Its default value is a string containing a single newline character, which means that an @@ -9508,6 +9542,23 @@ with a pound sign (`#'). `PROCINFO["version"]' The version of `gawk'. + The following additional elements in the array are available to + provide information about the MPFR and GMP libraries if your + version of `gawk' supports arbitrary precision numbers (*note + Arbitrary Precision Arithmetic::): + + `PROCINFO["mpfr_version"]' + The version of the GNU MPFR library. + + `PROCINFO["gmp_version"]' + The version of the GNU MP library. + + `PROCINFO["prec_max"]' + The maximum precision supported by MPFR. + + `PROCINFO["prec_min"]' + The minimum precision required by MPFR. + On some systems, there may be elements in the array, `"group1"' through `"groupN"' for some N. N is the number of supplementary groups that the process has. Use the `in' operator to test for @@ -13021,7 +13072,7 @@ example, in the following case: `gawk' will look up the actual function to call only once. -File: gawk.info, Node: Internationalization, Next: Advanced Features, Prev: Functions, Up: Top +File: gawk.info, Node: Internationalization, Next: Arbitrary Precision Arithmetic, Prev: Functions, Up: Top 10 Internationalization with `gawk' *********************************** @@ -13601,9 +13652,745 @@ writing, the latest version of GNU `gettext' is version 0.18.1 usage messages, warnings, and fatal errors in the local language. -File: gawk.info, Node: Advanced Features, Next: Library Functions, Prev: Internationalization, Up: Top +File: gawk.info, Node: Arbitrary Precision Arithmetic, Next: Advanced Features, Prev: Internationalization, Up: Top + +11 Arbitrary Precision Arithmetic with `gawk' +********************************************* + + There's a credibility gap: We don't know how much of the + computer's answers to believe. Novice computer users solve this + problem by implicitly trusting in the computer as an infallible + authority; they tend to believe that all digits of a printed + answer are significant. Disillusioned computer users have just the + opposite approach; they are constantly afraid that their answers + are almost meaningless. + + Donald Knuth(1) + + This minor node decsribes how to use the arbitrary precision (also +known as "multiple precision" or "infinite precision") numeric +capabilites 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 (GNU MPFR 3.1.0, GNU MP 5.0.3) + -| Copyright (C) 1989, 1991-2012 Free Software Foundation. + ... + + `gawk' uses the GNU MPFR (http://www.mpfr.org) and GNU MP +(http://gmplib.org) (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. + + Even if you aren't interested in arbitrary precision arithmetic, you +may still benifit from knowing about how `gawk' handles numbers in +general, and the limitations of doing arithmetic with ordinary `gawk' +numbers. + +* Menu: + +* Floating-point Programming:: Effective Floating-point Programming. +* Floating-point Representation:: Binary Floating-point Representation. +* Floating-point Context:: Floating-point Context. +* Rounding Mode:: Floating-point Rounding Mode. +* Arbitrary Precision Floats:: Arbitrary Precision Floating-point + Arithmetic with `gawk'. +* Setting Precision:: Setting the Working Precision. +* Setting Rounding Mode:: Setting the Rounding Mode. +* Floating-point Constants:: Representing Floating-point Constants. +* Changing Precision:: Changing the Precision of a Number. +* Exact Arithmetic:: Exact Arithmetic with Floating-point Numbers. +* Integer Programming:: Effective Integer Programming. +* Arbitrary Precision Integers:: Arbitrary Precision Integer + Arithmetic with `gawk'. +* MPFR and GMP Libraries:: Information About the MPFR and GMP Libraries. + + ---------- Footnotes ---------- + + (1) Donald E. Knuth. `The Art of Computer Programming'. Volume 2, +`Seminumerical Algorithms', third edition, 1998, ISBN 0-201-89683-4, p. +229. + + +File: gawk.info, Node: Floating-point Programming, Next: Floating-point Representation, Up: Arbitrary Precision Arithmetic + +11.1 Effective Floating-point Programming +========================================= + +Numerical programming is an extensive area; if you need to develop +sophisticated numerical algorithms then `gawk' may not be the ideal +tool, and this documentation may not be sufficient. It might require a +book or two to communicate how to compute with ideal accuracy and +precision and the result often depends on the particular application. + + NOTE: A floating-point calculation's "accuracy" is how close it + comes to the real value. This is as opposed to the "precision", + which usually refers to the number of bits used to represent the + number (see the Wikipedia article + (http://en.wikipedia.org/wiki/Accuracy_and_precision) for more + information). + + Binary floating-point representations and arithmetic are inexact. +Simple values like 0.1 cannot be precisely represented using binary +floating-point numbers, and the limited precision of floating-point +numbers means that slight changes in the order of operations or the +precision of intermediate storage can change the result. To make +matters worse with arbitrary precision floating-point, you can set the +precision before starting a computation, but then you cannot be sure of +the number of significant decimal places in the final result. + + Sometimes you need to think more about what you really want and +what's really happening. Consider the two numbers in the following +example: + + x = 0.875 # 1/2 + 1/4 + 1/8 + y = 0.425 + + Unlike the number in `y', the number stored in `x' is exactly +representable in binary since it can be written as a finite sum of one +or more fractions whose denominators are all powers of two. When +`gawk' reads a floating-point number from program source, it +automatically rounds that number to whatever precision your machine +supports. If you try to print the numeric content of a variable using +an output format string of `"%.17g"', it may not produce the same +number as you assigned to it: + + $ gawk 'BEGIN { x = 0.875; y = 0.425 + > printf("%0.17g, %0.17g\n", x, y) }' + -| 0.875, 0.42499999999999999 + + Often the error is so small you do not even notice it, and if you do, +you can always specify how much precision you would like in your output. +Usually this is a format string like `"%.15g"', which when used in the +previous example, produces an output identical to the input. + + Because the underlying representation can be little bit off from the +exact value, comparing floats to see if they are equal is generally not +a good idea. Here is an example where it does not work like you expect: + + $ gawk 'BEGIN { print (0.1 + 12.2 == 12.3) }' + -| 0 + + The loss of accuracy during a single computation with floating-point +numbers usually isn't enough to worry about. However, if you compute a +value which is the result of a sequence of floating point operations, +the error can accumulate and greatly affect the computation itself. +Here is an attempt to compute the value of the constant pi using one of +its many series representations: + + BEGIN { + x = 1.0 / sqrt(3.0) + n = 6 + for (i = 1; i < 30; i++) { + n = n * 2.0 + x = (sqrt(x * x + 1) - 1) / x + printf("%.15f\n", n * x) + } + } + + When run, the early errors propagating through later computations +cause the loop to terminate prematurely after an attempt to divide by +zero. + + $ gawk -f pi.awk + -| 3.215390309173475 + -| 3.159659942097510 + -| 3.146086215131467 + -| 3.142714599645573 + ... + -| 3.224515243534819 + -| 2.791117213058638 + -| 0.000000000000000 + error--> gawk: pi.awk:6: fatal: division by zero attempted + + Here is one more example where the inaccuracies in internal +representations yield an unexpected result: + + $ gawk 'BEGIN { + > for (d = 1.1; d <= 1.5; d += 0.1) + > i++ + > print i + > }' + -| 4 + + Can computation using aribitrary precision help with the previous +examples? If you are impatient to know, see *note Exact Arithmetic::. + + Instead of aribitrary precision floating-point arithmetic, often all +you need is an adjustment of your logic or a different order for the +operations in your calculation. The stability and the accuracy of the +computation of the constant pi in the previous example can be enhanced +by using the following simple algebraic transformation: + + (sqrt(x * x + 1) - 1) / x = x / (sqrt(x * x + 1) + x) + + There is no need to be unduly suspicious about the results from +floating-point arithmetic. The lesson to remember is that +floating-point math is always more complex than the math using pencil +and paper. In order to take advantage of the power of computer +floating-point, you need to know its limitations and work within them. +For most casual use of floating-point arithmetic, you will often get +the expected result in the end if you simply round the display of your +final results to the correct number of significant decimal digits. +Avoid presenting numerical data in a manner that implies better +precision than is actually the case. + + +File: gawk.info, Node: Floating-point Representation, Next: Floating-point Context, Prev: Floating-point Programming, Up: Arbitrary Precision Arithmetic + +11.2 Binary Floating-point Representation +========================================= + +Although floating-point representations vary from machine to machine, +the most commonly encountered representation is that defined by the +IEEE 754 Standard. An IEEE-754 format value has three components: + + * a sign bit telling whether the number is positive or negative, + + * an "exponent" giving its order of magnitude, E, + + * and a "significand", S, specifying the actual digits of the number. + + The value of the number is then S * 2^E. The first bit of a +non-zero binary significand is always one, so the significand in an +IEEE-754 format only includes the fractional part, leaving the leading +one implicit. + + Three of the standard IEEE-754 types are 32-bit single precision, +64-bit double precision and 128-bit quadruple precision. The standard +also specifies extended precision formats to allow greater precisions +and larger exponent ranges. + + +File: gawk.info, Node: Floating-point Context, Next: Rounding Mode, Prev: Floating-point Representation, Up: Arbitrary Precision Arithmetic + +11.3 Floating-point Context +=========================== + +A floating-point context defines the environment for arithmetic +operations. It governs precision, sets rules for rounding and limits +range for exponents. The context has the following primary components: + +`precision' + Precision of the floating-point format in bits. + +`emax' + Maximum exponent allowed for this format. + +`emin' + Minimum exponent allowed for this format. + +`underflow behavior' + The format may or may not support gradual underflow. + +`rounding' + The rounding mode of this context. + + *note table-ieee-formats:: lists the precision and exponent field +values for the basic IEEE-754 binary formats: + +Name Total bits Precision emin emax +--------------------------------------------------------------------------- +Single 32 24 -126 +127 +Double 64 53 -1022 +1023 +Quadruple 128 113 -16382 +16383 + +Table 11.1: Basic IEEE Formats + + NOTE: The precision numbers include the implied leading one that + gives them one extra bit of significand. + + A floating-point context can also determine which signals are treated +as exceptions, and can set rules for arithmetic with special values. +Please consult the IEEE-754 standard or other resources for details. + + `gawk' ordinarily uses the hardware double precision representation +for numbers. On most systems, this is IEEE-754 floating-point format, +corresponding to 64-bit binary with 53 bits of precision. + + NOTE: In case an underflow occurs, the standard allows, but does + not require, the result from an arithmetic operation to be a + number smaller than the smallest nonzero normalized number. Such + numbers do not have as many significant digits as normal numbers, + and are called "denormals" or "subnormals". The alternative, + simply returning a zero, is called "flush to zero". The basic + IEEE-754 binary formats support subnormal numbers. + + +File: gawk.info, Node: Rounding Mode, Next: Arbitrary Precision Floats, Prev: Floating-point Context, Up: Arbitrary Precision Arithmetic + +11.4 Floating-point Rounding Mode +================================= + +The "rounding mode" specifies the behavior for the results of numerical +operations when discarding extra precision. Each rounding mode indicates +how the least significant returned digit of a rounded result is to be +calculated. The `ROUNDMODE' variable (*note Setting Rounding Mode::) +provides program level control over the rounding mode. *note +table-rounding-modes:: lists the IEEE-754 defined rounding modes: + +Rounding Mode IEEE Name `ROUNDMODE' +--------------------------------------------------------------------------- +Round to nearest, ties to even `roundTiesToEven' `"N"' or `"n"' +Round toward plus Infinity `roundTowardPositive' `"U"' or `"u"' +Round toward negative Infinity `roundTowardNegative' `"D"' or `"d"' +Round toward zero `roundTowardZero' `"Z"' or `"z"' +Round to nearest, ties away `roundTiesToAway' `"A"' or `"a"' +from zero + +Table 11.2: Rounding Modes + + The default mode `roundTiesToEven' is the most preferred, but the +least intuitive. This method does the obvious thing for most values, by +rounding them up or down to the nearest digit. For example, rounding +1.132 to two digits yields 1.13, and rounding 1.157 yields 1.16. + + However, when it comes to rounding a value that is exactly halfway +between, things do not work the way you probably learned in school. In +this case, the number is rounded to the nearest even digit. So +rounding 0.125 to two digits rounds down to 0.12, but rounding 0.6875 +to three digits rounds up to 0.688. You probably have already +encountered this rounding mode when using the `printf' routine to +format floating-point numbers. For example: + + BEGIN { + x = -4.5 + for (i = 1; i < 10; i++) { + x += 1.0 + printf("%4.1f => %2.0f\n", x, x) + } + } + +produces the following output when run(1): + + -3.5 => -4 + -2.5 => -2 + -1.5 => -2 + -0.5 => 0 + 0.5 => 0 + 1.5 => 2 + 2.5 => 2 + 3.5 => 4 + 4.5 => 4 + + The theory behind the rounding mode `roundTiesToEven' is that it +more or less evenly distributes upward and downward rounds of exact +halves, which might cause the round-off error to cancel itself out. +This is the default rounding mode used in IEEE-754 computing functions +and operators. + + The other rounding modes are rarely used. Round toward positive +infinity (`roundTowardPositive') and round toward negative infinity +(`roundTowardNegative') are often used to implement interval arithmetic, +where you adjust the rounding mode to calculate upper and lower bounds +for the range of output. The `roundTowardZero' mode can be used for +converting floating-point numbers to integers. The rounding mode +`roundTiesToAway' rounds the result to the nearest number and selects +the number with the larger magnitude if a tie occurs. + + Some numerical analysts will tell you that your choice of rounding +style has tremendous impact on the final outcome, and advise you to +wait until final output for any rounding. Instead, you can often +achieve this goal by setting the precision initially to some value +sufficiently larger than the final desired precision, so that the +accumulation of round-off error does not influence the outcome. If you +suspect that results from your computation are sensitive to +accumulation of round-off error, one way to be sure is to look for a +significant difference in output when you change the rounding mode. + + ---------- Footnotes ---------- + + (1) It is possible for the output to be completely different if the +C library in your system does not use the IEEE-754 even-rounding rule +to round halfway cases for `printf()'. + + +File: gawk.info, Node: Arbitrary Precision Floats, Next: Setting Precision, Prev: Rounding Mode, Up: Arbitrary Precision Arithmetic + +11.5 Arbitrary Precision Floating-point Arithmetic with `gawk' +============================================================== + +`gawk' uses the GNU MPFR library for arbitrary precision floating-point +arithmetic. The MPFR library provides precise control over precisions +and rounding modes, and gives correctly rounded reproducible +platform-independent results. With the command-line option `--bignum' +or `-M', all floating-point arithmetic operators and numeric functions +can yield results to any desired precision level supported by MPFR. +Two built-in variables `PREC' (*note Setting Precision::) and +`ROUNDMODE' (*note Setting Rounding Mode::) provide control over the +working precision and the rounding mode. The precision and the +rounding mode are set globally for every operation to follow. + + The default working precision for arbitrary precision floats is 53, +and the default value for `ROUNDMODE' is `"N"', which selects the +IEEE-754 `roundTiesToEven' (*note Rounding Mode::) rounding mode.(1) +`gawk' uses the default exponent range in MPFR (EMAX = 2^30 - 1, EMIN = +-EMAX) for all floating-point contexts. There is no explicit mechanism +to adjust the exponent range. MPFR does not implement subnormal +numbers by default, and this behavior cannot be changed in `gawk'. + + NOTE: When emulating an IEEE-754 format (*note Setting + Precision::), `gawk' internally adjusts the exponent range to the + value defined for the format and also performs computations needed + for gradual underflow (subnormal numbers). + + NOTE: MPFR numbers are variable-size entities, consuming only as + much space as needed to store the significant digits. Since the + performance using MPFR numbers pales in comparison to doing math + using the underlying machine types, you should consider using only + as much precision as needed by your program. + + ---------- Footnotes ---------- + + (1) The default precision is 53, since according to the MPFR +documentation, the library should be able to exactly reproduce all +computations with double-precision machine floating-point numbers +(`double' type in C), except the default exponent range is much wider +and subnormal numbers are not implemented. + + +File: gawk.info, Node: Setting Precision, Next: Setting Rounding Mode, Prev: Arbitrary Precision Floats, Up: Arbitrary Precision Arithmetic + +11.6 Setting the Working Precision +================================== + +`gawk' uses a global working precision; it does not keep track of the +precision or accuracy of individual numbers. Performing an arithmetic +operation or calling a built-in function rounds the result to the +current working precision. The default working precision is 53 which +can be modified using the built-in variable `PREC'. You can also set the +value to one of the following pre-defined case-insensitive strings to +emulate an IEEE-754 binary format: + +`PREC' IEEE-754 Binary Format +--------------------------------------------------- +`"half"' 16-bit half-precision. +`"single"' Basic 32-bit single precision. +`"double"' Basic 64-bit double precision. +`"quad"' Basic 128-bit quadruple precision. +`"oct"' 256-bit octuple precision. + + The following example illustrates the effects of changing precision +on arithmetic operations: + + $ gawk -M -vPREC=100 'BEGIN { x = 1.0e-400; print x + 0; \ + > PREC = "double"; print x + 0 }' + -| 1e-400 + -| 0 + + Binary and decimal precisions are related approximately according to +the formula: + + PREC = 3.322 * DPS + +Here, PREC denotes the binary precision (measured in bits) and DPS +(short for decimal places) is the decimal digits. We can easily +calculate how many decimal digits the 53-bit significand of an IEEE +double is equivalent to: 53 / 3.332 which is equal to about 15.95. But +what does 15.95 digits actually mean? It depends whether you are +concerned about how many digits you can rely on, or how many digits you +need. + + It is important to know how many bits it takes to uniquely identify +a double-precision value (the C type `double'). If you want to convert +from `double' to decimal and back to `double' (e.g., saving a `double' +representing an intermediate result to a file, and later reading it +back to restart the computation), then a few more decimal digits are +required. 17 digits is generally enough for a `double'. + + It can also be important to know what decimal numbers can be uniquely +represented with a `double'. If you want to convert from decimal to +`double' and back again, 15 digits is the most that you can get. Stated +differently, you should not present the numbers from your +floating-point computations with more than 15 significant digits in +them. + + Conversely, it takes a precision of 332 bits to hold an approximation +of constant pi that is accurate to 100 decimal places. You should +always add some extra bits in order to avoid the confusing round-off +issues that occur because numbers are stored internally in binary. + + +File: gawk.info, Node: Setting Rounding Mode, Next: Floating-point Constants, Prev: Setting Precision, Up: Arbitrary Precision Arithmetic + +11.7 Setting the Rounding Mode +============================== + +The built-in variable `ROUNDMODE' has the default value `"N"', which +selects the IEEE-754 rounding mode `roundTiesToEven'. The other +possible values for `ROUNDMODE' are `"U"' for rounding mode +`roundTowardPositive', `"D"' for `roundTowardNegative', and `"Z"' for +`roundTowardZero'. `gawk' also accepts `"A"' to select the IEEE-754 +mode `roundTiesToAway' if your version of the MPFR library supports it; +otherwise setting `ROUNDMODE' to this value has no effect. *Note +Rounding Mode::, for the meanings of the various rounding modes. + + Here is an example of how to change the default rounding behavior of +`printf''s output: + + $ gawk -M -vROUNDMODE="Z" 'BEGIN { printf("%.2f\n", 1.378) }' + -| 1.37 + + +File: gawk.info, Node: Floating-point Constants, Next: Changing Precision, Prev: Setting Rounding Mode, Up: Arbitrary Precision Arithmetic + +11.8 Representing Floating-point Constants +========================================== + +Be wary of floating-point constants! When reading a floating-point +constant from program source code, `gawk' uses the default precision, +unless overridden by an assignment to the special variable `PREC' on +the command line, to store it internally as a MPFR number. Changing +the precision using `PREC' in the program text does not change the +precision of a constant. If you need to represent a floating-point +constant at a higher precision than the default and cannot use a +command line assignment to `PREC', you should either specify the +constant as a string, or a rational number whenever possible. The +following example illustrates the differences among various ways to +print a floating-point constant: + + $ gawk -M 'BEGIN { PREC = 113; printf("%0.25f\n", 0.1) }' + -| 0.1000000000000000055511151 + $ gawk -M -vPREC = 113 'BEGIN { printf("%0.25f\n", 0.1) }' + -| 0.1000000000000000000000000 + $ gawk -M 'BEGIN { PREC = 113; printf("%0.25f\n", "0.1") }' + -| 0.1000000000000000000000000 + $ gawk -M 'BEGIN { PREC = 113; printf("%0.25f\n", 1/10) }' + -| 0.1000000000000000000000000 + + In the first case, the number is stored with the default precision +of 53. + + +File: gawk.info, Node: Changing Precision, Next: Exact Arithmetic, Prev: Floating-point Constants, Up: Arbitrary Precision Arithmetic + +11.9 Changing the Precision of a Number +======================================= + + The point is that in any variable-precision package, a decision is + made on how to treat numbers given as data, or arising in + intermediate results, which are represented in floating-point + format to a precision lower than working precision. Do we promote + them to full membership of the high-precision club, or do we treat + them and all their associates as second-class citizens? Sometimes + the first course is proper, sometimes the second, and it takes + careful analysis to tell which. + + Dirk Laurie(1) + + `gawk' does not implicitly modify the precision of any previously +computed results when the working precision is changed with an +assignment to `PREC'. The precision of a number is always the one that +was used at the time of its creation, and there is no way for the user +to explicitly change it afterwards. However, since the result of a +floating-point arithmetic operation is always an arbitrary precision +floating-point value--with a precision set by the value of `PREC'--one +of the following workarounds effectively accomplishes the desired +behavior: + + x = x + 0.0 + +or: + + x += 0.0 + + ---------- Footnotes ---------- + + (1) Dirk Laurie. `Variable-precision Arithmetic Considered Perilous +- A Detective Story'. Electronic Transactions on Numerical Analysis. +Volume 28, pp. 168-173, 2008. + + +File: gawk.info, Node: Exact Arithmetic, Next: Integer Programming, Prev: Changing Precision, Up: Arbitrary Precision Arithmetic + +11.10 Exact Arithmetic with Floating-point Numbers +================================================== + + CAUTION: Never depend on the exactness of floating-point + arithmetic, even for apparently simple expressions! -11 Advanced Features of `gawk' + Can arbitrary precision arithmetic give exact results? There are no +easy answers. The standard rules of algebra often do not apply when +using floating-point arithmetic. Among other things, the distributive +and associative laws do not hold completely, and order of operation may +be important for your computation. Rounding error, cumulative precision +loss and underflow are often troublesome. + + When `gawk' tests the expressions `0.1 + 12.2' and `12.3' for +equality using the machine double precision arithmetic, it decides that +they are not equal! (*Note Floating-point Programming::.) You can get +the result you want by increasing the precision; 56 in this case will +get the job done: + + $ gawk -M -vPREC=56 'BEGIN { print (0.1 + 12.2 == 12.3) }' + -| 1 + + If adding more bits is good, perhaps adding even more bits of +precision is better? Here is what happens if we use an even larger +value of `PREC': + + $ gawk -M -vPREC=201 'BEGIN { print (0.1 + 12.2 == 12.3) }' + -| 0 + + This is not a bug in `gawk' or in the MPFR library. It is easy to +forget that the finite number of bits used to store the value is often +just an approximation after proper rounding. The test for equality +succeeds if and only if _all_ bits in the two operands are exactly the +same. Since this is not necessarily true after floating-point +computations with a particular precision and effective rounding rule, a +straight test for equality may not work. + + So, don't assume that floating-point values can be compared for +equality. You should also exercise caution when using other forms of +comparisons. The standard way to compare between floating-point +numbers is to determine how much error (or "tolerance") you will allow +in a comparison and check to see if one value is within this error +range of the other. + + In applications where 15 or fewer decimal places suffice, hardware +double precision arithmetic can be adequate, and is usually much faster. +But you do need to keep in mind that every floating-point operation can +suffer a new rounding error with catastrophic consequences as +illustrated by our attempt to compute the value of the constant pi, +(*note Floating-point Programming::). Extra precision can greatly +enhance the stability and the accuracy of your computation in such +cases. + + Repeated addition is not necessarily equivalent to multiplication in +floating-point arithmetic. In the last example (*note Floating-point +Programming::), you may or may not succeed in getting the correct +result by choosing an arbitrarily large value for `PREC'. Reformulation +of the problem at hand is often the correct approach in such situations. + + +File: gawk.info, Node: Integer Programming, Next: Arbitrary Precision Integers, Prev: Exact Arithmetic, Up: Arbitrary Precision Arithmetic + +11.11 Effective Integer Programming +=================================== + +As has been mentioned already, `gawk' ordinarily uses hardware double +precision with 64-bit IEEE binary floating-point representation for +numbers on most systems. A large integer like 9007199254740997 has a +binary representation that, although finite, is more than 53 bits long; +it must also be rounded to 53 bits. The biggest integer that can be +stored in a C `double' is usually the same as the largest possible +value of a `double'. If your system `double' is an IEEE 64-bit +`double', this largest possible value is an integer and can be +represented precisely. What more should one know about integers? + + If you want to know what is the largest integer, such that it and +all smaller integers can be stored in 64-bit doubles without losing +precision, then the answer is 2^53. The next representable number is +the even number 2^53 + 2, meaning it is unlikely that you will be able +to make `gawk' print 2^53 + 1 in integer format. The range of integers +exactly representable by a 64-bit double is [-2^53, 2^53]. If you ever +see an integer outside this range in `gawk' using 64-bit doubles, you +have reason to be very suspicious about the accuracy of the output. +Here is a simple program with erroneous output: + + $ gawk 'BEGIN { i = 2^53 - 1; for (j = 0; j < 4; j++) print i + j }' + -| 9007199254740991 + -| 9007199254740992 + -| 9007199254740992 + -| 9007199254740994 + + The lesson is to not assume that any large integer printed by `gawk' +represents an exact result from your computation, especially if it wraps +around on your screen. + + +File: gawk.info, Node: Arbitrary Precision Integers, Next: MPFR and GMP Libraries, Prev: Integer Programming, Up: Arbitrary Precision Arithmetic + +11.12 Arbitrary Precision Integer Arithmetic with `gawk' +======================================================== + +If the option `--bignum' or `-M' is specified, `gawk' performs all +integer arithmetic using GMP arbitrary precision integers. Any number +that looks like an integer in a program source or data file is stored +as an arbitrary precision integer. The size of the integer is limited +only by your computer's memory. The current floating-point context has +no effect on operations involving integers. For example, the following +computes 5^4^3^2, the result of which is beyond the limits of ordinary +`gawk' numbers: + + $ gawk -M 'BEGIN { + > x = 5^4^3^2 + > print "# of digits =", length(x) + > print substr(x, 1, 20), "...", substr(x, length(x) - 19, 20) + > }' + -| # of digits = 183231 + -| 62060698786608744707 ... 92256259918212890625 + + If you were to compute the same value using arbitrary precision +floating-point values instead, the precision needed for correct output +(using the formula `prec = 3.322 * dps'), would be 3.322 x 183231, or +608693. + + The result from an arithmetic operation with an integer and a +floating-point value is a floating-point value with a precision equal +to the working precision. The following program calculates the eighth +term in Sylvester's sequence(1) using a recurrence: + + $ gawk -M 'BEGIN { + > s = 2.0 + > for (i = 1; i <= 7; i++) + > s = s * (s - 1) + 1 + > print s + > }' + -| 113423713055421845118910464 + + The output differs from the acutal number, +113423713055421844361000443, because the default precision of 53 is not +enough to represent the floating-point results exactly. You can either +increase the precision (100 is enough in this case), or replace the +floating-point constant `2.0' with an integer, to perform all +computations using integer arithmetic to get the correct output. + + It will sometimes be necessary for `gawk' to implicitly convert an +arbitrary precision integer into an arbitrary precision floating-point +value. This is primarily because the MPFR library does not always +provide the relevant interface to process arbitrary precision integers +or mixed-mode numbers as needed by an operation or function. In such a +case, the precision is set to the minimum value necessary for exact +conversion, and the working precision is not used for this purpose. If +this is not what you need or want, you can employ a subterfuge like +this: + + gawk -M 'BEGIN { n = 13; print (n + 0.0) % 2.0 }' + + You can avoid this issue altogether by specifying the number as a +float to begin with: + + gawk -M 'BEGIN { n = 13.0; print n % 2.0 }' + + Note that for the particular example above, there is unlikely to be a +reason for simply not using the following: + + gawk -M 'BEGIN { n = 13; print n % 2 }' + + ---------- Footnotes ---------- + + (1) Weisstein, Eric W. `Sylvester's Sequence'. From MathWorld-A +Wolfram Web Resource. +`http://mathworld.wolfram.com/SylvestersSequence.html' + + +File: gawk.info, Node: MPFR and GMP Libraries, Prev: Arbitrary Precision Integers, Up: Arbitrary Precision Arithmetic + +11.13 Information About the MPFR and GMP Libraries +================================================== + +There are a few elements available in the `PROCINFO' array to provide +information about the MPFR and GMP libraries. *Note Auto-set::, for +more information. + + +File: gawk.info, Node: Advanced Features, Next: Library Functions, Prev: Arbitrary Precision Arithmetic, Up: Top + +12 Advanced Features of `gawk' ****************************** Write documentation as if whoever reads it is a violent psychopath @@ -13636,7 +14423,7 @@ and likely to change, its description is relegated to an appendix. File: gawk.info, Node: Nondecimal Data, Next: Array Sorting, Up: Advanced Features -11.1 Allowing Nondecimal Input Data +12.1 Allowing Nondecimal Input Data =================================== If you run `gawk' with the `--non-decimal-data' option, you can have @@ -13678,7 +14465,7 @@ request it. File: gawk.info, Node: Array Sorting, Next: Two-way I/O, Prev: Nondecimal Data, Up: Advanced Features -11.2 Controlling Array Traversal and Array Sorting +12.2 Controlling Array Traversal and Array Sorting ================================================== `gawk' lets you control the order in which a `for (i in array)' loop @@ -13697,7 +14484,7 @@ to order the elements during sorting. File: gawk.info, Node: Controlling Array Traversal, Next: Array Sorting Functions, Up: Array Sorting -11.2.1 Controlling Array Traversal +12.2.1 Controlling Array Traversal ---------------------------------- By default, the order in which a `for (i in array)' loop scans an array @@ -13928,7 +14715,7 @@ the default. File: gawk.info, Node: Array Sorting Functions, Prev: Controlling Array Traversal, Up: Array Sorting -11.2.2 Sorting Array Values and Indices with `gawk' +12.2.2 Sorting Array Values and Indices with `gawk' --------------------------------------------------- In most `awk' implementations, sorting an array requires writing a @@ -14023,7 +14810,7 @@ extensions, they are not available in that case. File: gawk.info, Node: Two-way I/O, Next: TCP/IP Networking, Prev: Array Sorting, Up: Advanced Features -11.3 Two-Way Communications with Another Process +12.3 Two-Way Communications with Another Process ================================================ From: brennan@whidbey.com (Mike Brennan) @@ -14158,7 +14945,7 @@ regular pipes. File: gawk.info, Node: TCP/IP Networking, Next: Profiling, Prev: Two-way I/O, Up: Advanced Features -11.4 Using `gawk' for Network Programming +12.4 Using `gawk' for Network Programming ========================================= `EMISTERED': @@ -14235,7 +15022,7 @@ examples. File: gawk.info, Node: Profiling, Prev: TCP/IP Networking, Up: Advanced Features -11.5 Profiling Your `awk' Programs +12.5 Profiling Your `awk' Programs ================================== You may produce execution traces of your `awk' programs. This is done @@ -14453,7 +15240,7 @@ without any execution counts. File: gawk.info, Node: Library Functions, Next: Sample Programs, Prev: Advanced Features, Up: Top -12 A Library of `awk' Functions +13 A Library of `awk' Functions ******************************* *note User-defined::, describes how to write your own `awk' functions. @@ -14525,7 +15312,7 @@ contents of the input record. File: gawk.info, Node: Library Names, Next: General Functions, Up: Library Functions -12.1 Naming Library Function Global Variables +13.1 Naming Library Function Global Variables ============================================= Due to the way the `awk' language evolved, variables are either @@ -14605,7 +15392,7 @@ verifying this. File: gawk.info, Node: General Functions, Next: Data File Management, Prev: Library Names, Up: Library Functions -12.2 General Programming +13.2 General Programming ======================== This minor node presents a number of functions that are of general @@ -14628,7 +15415,7 @@ programming use. File: gawk.info, Node: Strtonum Function, Next: Assert Function, Up: General Functions -12.2.1 Converting Strings To Numbers +13.2.1 Converting Strings To Numbers ------------------------------------ The `strtonum()' function (*note String Functions::) is a `gawk' @@ -14712,7 +15499,7 @@ be tested with `gawk' and the results compared to the built-in File: gawk.info, Node: Assert Function, Next: Round Function, Prev: Strtonum Function, Up: General Functions -12.2.2 Assertions +13.2.2 Assertions ----------------- When writing large programs, it is often useful to know that a @@ -14798,7 +15585,7 @@ rule always ends with an `exit' statement. File: gawk.info, Node: Round Function, Next: Cliff Random Function, Prev: Assert Function, Up: General Functions -12.2.3 Rounding Numbers +13.2.3 Rounding Numbers ----------------------- The way `printf' and `sprintf()' (*note Printf::) perform rounding @@ -14844,7 +15631,7 @@ might be useful if your `awk''s `printf' does unbiased rounding: File: gawk.info, Node: Cliff Random Function, Next: Ordinal Functions, Prev: Round Function, Up: General Functions -12.2.4 The Cliff Random Number Generator +13.2.4 The Cliff Random Number Generator ---------------------------------------- The Cliff random number generator @@ -14873,7 +15660,7 @@ might try using this function instead. File: gawk.info, Node: Ordinal Functions, Next: Join Function, Prev: Cliff Random Function, Up: General Functions -12.2.5 Translating Between Characters and Numbers +13.2.5 Translating Between Characters and Numbers ------------------------------------------------- One commercial implementation of `awk' supplies a built-in function, @@ -14971,7 +15758,7 @@ extensions, you can simplify `_ord_init' to loop from 0 to 255. File: gawk.info, Node: Join Function, Next: Gettimeofday Function, Prev: Ordinal Functions, Up: General Functions -12.2.6 Merging an Array into a String +13.2.6 Merging an Array into a String ------------------------------------- When doing string processing, it is often useful to be able to join all @@ -15018,7 +15805,7 @@ makes string operations more difficult than they really need to be. File: gawk.info, Node: Gettimeofday Function, Prev: Join Function, Up: General Functions -12.2.7 Managing the Time of Day +13.2.7 Managing the Time of Day ------------------------------- The `systime()' and `strftime()' functions described in *note Time @@ -15100,7 +15887,7 @@ optional timestamp value to use instead of the current time. File: gawk.info, Node: Data File Management, Next: Getopt Function, Prev: General Functions, Up: Library Functions -12.3 Data File Management +13.3 Data File Management ========================= This minor node presents functions that are useful for managing @@ -15117,7 +15904,7 @@ command-line data files. File: gawk.info, Node: Filetrans Function, Next: Rewind Function, Up: Data File Management -12.3.1 Noting Data File Boundaries +13.3.1 Noting Data File Boundaries ---------------------------------- The `BEGIN' and `END' rules are each executed exactly once at the @@ -15215,7 +16002,7 @@ it provides an easy way to do per-file cleanup processing. File: gawk.info, Node: Rewind Function, Next: File Checking, Prev: Filetrans Function, Up: Data File Management -12.3.2 Rereading the Current File +13.3.2 Rereading the Current File --------------------------------- Another request for a new built-in function was for a `rewind()' @@ -15257,7 +16044,7 @@ Nextfile Statement::). File: gawk.info, Node: File Checking, Next: Empty Files, Prev: Rewind Function, Up: Data File Management -12.3.3 Checking for Readable Data Files +13.3.3 Checking for Readable Data Files --------------------------------------- Normally, if you give `awk' a data file that isn't readable, it stops @@ -15286,7 +16073,7 @@ in the list). See also *note ARGC and ARGV::. File: gawk.info, Node: Empty Files, Next: Ignoring Assigns, Prev: File Checking, Up: Data File Management -12.3.4 Checking For Zero-length Files +13.3.4 Checking For Zero-length Files ------------------------------------- All known `awk' implementations silently skip over zero-length files. @@ -15343,7 +16130,7 @@ intervening value in `ARGV' is a variable assignment. File: gawk.info, Node: Ignoring Assigns, Prev: Empty Files, Up: Data File Management -12.3.5 Treating Assignments as File Names +13.3.5 Treating Assignments as File Names ----------------------------------------- Occasionally, you might not want `awk' to process command-line variable @@ -15386,7 +16173,7 @@ arguments are left alone. File: gawk.info, Node: Getopt Function, Next: Passwd Functions, Prev: Data File Management, Up: Library Functions -12.4 Processing Command-Line Options +13.4 Processing Command-Line Options ==================================== Most utilities on POSIX compatible systems take options on the command @@ -15679,7 +16466,7 @@ have left it alone, since using `substr()' is more portable. File: gawk.info, Node: Passwd Functions, Next: Group Functions, Prev: Getopt Function, Up: Library Functions -12.5 Reading the User Database +13.5 Reading the User Database ============================== The `PROCINFO' array (*note Built-in Variables::) provides access to @@ -15922,7 +16709,7 @@ network database. File: gawk.info, Node: Group Functions, Next: Walking Arrays, Prev: Passwd Functions, Up: Library Functions -12.6 Reading the Group Database +13.6 Reading the Group Database =============================== Much of the discussion presented in *note Passwd Functions::, applies @@ -16156,7 +16943,7 @@ very simple, relying on `awk''s associative arrays to do work. File: gawk.info, Node: Walking Arrays, Prev: Group Functions, Up: Library Functions -12.7 Traversing Arrays of Arrays +13.7 Traversing Arrays of Arrays ================================ *note Arrays of Arrays::, described how `gawk' provides arrays of @@ -16207,7 +16994,7 @@ value. Here is a main program to demonstrate: File: gawk.info, Node: Sample Programs, Next: Debugger, Prev: Library Functions, Up: Top -13 Practical `awk' Programs +14 Practical `awk' Programs *************************** *note Library Functions::, presents the idea that reading programs in a @@ -16227,7 +17014,7 @@ Library Functions::. File: gawk.info, Node: Running Examples, Next: Clones, Up: Sample Programs -13.1 Running the Example Programs +14.1 Running the Example Programs ================================= To run a given program, you would typically do something like this: @@ -16250,7 +17037,7 @@ OPTIONS are any command-line options for the program that start with a File: gawk.info, Node: Clones, Next: Miscellaneous Programs, Prev: Running Examples, Up: Sample Programs -13.2 Reinventing Wheels for Fun and Profit +14.2 Reinventing Wheels for Fun and Profit ========================================== This minor node presents a number of POSIX utilities implemented in @@ -16280,7 +17067,7 @@ programming for "real world" tasks. File: gawk.info, Node: Cut Program, Next: Egrep Program, Up: Clones -13.2.1 Cutting out Fields and Columns +14.2.1 Cutting out Fields and Columns ------------------------------------- The `cut' utility selects, or "cuts," characters or fields from its @@ -16539,7 +17326,7 @@ solution to the problem of picking the input line apart by characters. File: gawk.info, Node: Egrep Program, Next: Id Program, Prev: Cut Program, Up: Clones -13.2.2 Searching for Regular Expressions in Files +14.2.2 Searching for Regular Expressions in Files ------------------------------------------------- The `egrep' utility searches files for patterns. It uses regular @@ -16771,7 +17558,7 @@ the translated line, not the original. File: gawk.info, Node: Id Program, Next: Split Program, Prev: Egrep Program, Up: Clones -13.2.3 Printing out User Information +14.2.3 Printing out User Information ------------------------------------ The `id' utility lists a user's real and effective user ID numbers, @@ -16878,7 +17665,7 @@ body never executes. File: gawk.info, Node: Split Program, Next: Tee Program, Prev: Id Program, Up: Clones -13.2.4 Splitting a Large File into Pieces +14.2.4 Splitting a Large File into Pieces ----------------------------------------- The `split' program splits large text files into smaller pieces. Usage @@ -16986,7 +17773,7 @@ not relevant for what the program aims to demonstrate. File: gawk.info, Node: Tee Program, Next: Uniq Program, Prev: Split Program, Up: Clones -13.2.5 Duplicating Output into Multiple Files +14.2.5 Duplicating Output into Multiple Files --------------------------------------------- The `tee' program is known as a "pipe fitting." `tee' copies its @@ -17074,7 +17861,7 @@ N input records and M output files, the first method only executes N File: gawk.info, Node: Uniq Program, Next: Wc Program, Prev: Tee Program, Up: Clones -13.2.6 Printing Nonduplicated Lines of Text +14.2.6 Printing Nonduplicated Lines of Text ------------------------------------------- The `uniq' utility reads sorted lines of data on its standard input, @@ -17293,7 +18080,7 @@ line of input data: File: gawk.info, Node: Wc Program, Prev: Uniq Program, Up: Clones -13.2.7 Counting Things +14.2.7 Counting Things ---------------------- The `wc' (word count) utility counts lines, words, and characters in @@ -17438,7 +18225,7 @@ characters, not bytes. File: gawk.info, Node: Miscellaneous Programs, Prev: Clones, Up: Sample Programs -13.3 A Grab Bag of `awk' Programs +14.3 A Grab Bag of `awk' Programs ================================= This minor node is a large "grab bag" of miscellaneous programs. We @@ -17465,7 +18252,7 @@ hope you find them both interesting and enjoyable. File: gawk.info, Node: Dupword Program, Next: Alarm Program, Up: Miscellaneous Programs -13.3.1 Finding Duplicated Words in a Document +14.3.1 Finding Duplicated Words in a Document --------------------------------------------- A common error when writing large amounts of prose is to accidentally @@ -17513,7 +18300,7 @@ word, comparing it to the previous one: File: gawk.info, Node: Alarm Program, Next: Translate Program, Prev: Dupword Program, Up: Miscellaneous Programs -13.3.2 An Alarm Clock Program +14.3.2 An Alarm Clock Program ----------------------------- Nothing cures insomnia like a ringing alarm clock. @@ -17646,7 +18433,7 @@ necessary: File: gawk.info, Node: Translate Program, Next: Labels Program, Prev: Alarm Program, Up: Miscellaneous Programs -13.3.3 Transliterating Characters +14.3.3 Transliterating Characters --------------------------------- The system `tr' utility transliterates characters. For example, it is @@ -17772,7 +18559,7 @@ split each character in a string into separate array elements. File: gawk.info, Node: Labels Program, Next: Word Sorting, Prev: Translate Program, Up: Miscellaneous Programs -13.3.4 Printing Mailing Labels +14.3.4 Printing Mailing Labels ------------------------------ Here is a "real world"(1) program. This script reads lists of names and @@ -17879,7 +18666,7 @@ something done." File: gawk.info, Node: Word Sorting, Next: History Sorting, Prev: Labels Program, Up: Miscellaneous Programs -13.3.5 Generating Word-Usage Counts +14.3.5 Generating Word-Usage Counts ----------------------------------- When working with large amounts of text, it can be interesting to know @@ -17983,7 +18770,7 @@ operating system documentation for more information on how to use the File: gawk.info, Node: History Sorting, Next: Extract Program, Prev: Word Sorting, Up: Miscellaneous Programs -13.3.6 Removing Duplicates from Unsorted Text +14.3.6 Removing Duplicates from Unsorted Text --------------------------------------------- The `uniq' program (*note Uniq Program::), removes duplicate lines from @@ -18030,7 +18817,7 @@ seen. File: gawk.info, Node: Extract Program, Next: Simple Sed, Prev: History Sorting, Up: Miscellaneous Programs -13.3.7 Extracting Programs from Texinfo Source Files +14.3.7 Extracting Programs from Texinfo Source Files ---------------------------------------------------- The nodes *note Library Functions::, and *note Sample Programs::, are @@ -18230,7 +19017,7 @@ function. Consider how you might use it to simplify the code. File: gawk.info, Node: Simple Sed, Next: Igawk Program, Prev: Extract Program, Up: Miscellaneous Programs -13.3.8 A Simple Stream Editor +14.3.8 A Simple Stream Editor ----------------------------- The `sed' utility is a stream editor, a program that reads a stream of @@ -18311,7 +19098,7 @@ the single rule handles the printing scheme outlined above, using File: gawk.info, Node: Igawk Program, Next: Anagram Program, Prev: Simple Sed, Up: Miscellaneous Programs -13.3.9 An Easy Way to Use Library Functions +14.3.9 An Easy Way to Use Library Functions ------------------------------------------- In *note Include Files::, we saw how `gawk' provides a built-in @@ -18708,7 +19495,7 @@ can loop forever if the file exists but is empty. Caveat emptor. File: gawk.info, Node: Anagram Program, Next: Signature Program, Prev: Igawk Program, Up: Miscellaneous Programs -13.3.10 Finding Anagrams From A Dictionary +14.3.10 Finding Anagrams From A Dictionary ------------------------------------------ An interesting programming challenge is to search for "anagrams" in a @@ -18798,7 +19585,7 @@ otherwise the anagrams would appear in arbitrary order: File: gawk.info, Node: Signature Program, Prev: Anagram Program, Up: Miscellaneous Programs -13.3.11 And Now For Something Completely Different +14.3.11 And Now For Something Completely Different -------------------------------------------------- The following program was written by Davide Brini and is published on @@ -18825,7 +19612,7 @@ supplies the following copyright terms: File: gawk.info, Node: Debugger, Next: Language History, Prev: Sample Programs, Up: Top -14 Debugging `awk' Programs +15 Debugging `awk' Programs *************************** It would be nice if computer programs worked perfectly the first time @@ -18849,7 +19636,7 @@ program is easy. File: gawk.info, Node: Debugging, Next: Sample Debugging Session, Up: Debugger -14.1 Introduction to `gawk' Debugger +15.1 Introduction to `gawk' Debugger ==================================== This minor node introduces debugging in general and begins the @@ -18864,7 +19651,7 @@ discussion of debugging in `gawk'. File: gawk.info, Node: Debugging Concepts, Next: Debugging Terms, Up: Debugging -14.1.1 Debugging in General +15.1.1 Debugging in General --------------------------- (If you have used debuggers in other languages, you may want to skip @@ -18904,7 +19691,7 @@ functional program that you or someone else wrote). File: gawk.info, Node: Debugging Terms, Next: Awk Debugging, Prev: Debugging Concepts, Up: Debugging -14.1.2 Additional Debugging Concepts +15.1.2 Additional Debugging Concepts ------------------------------------ Before diving in to the details, we need to introduce several important @@ -18956,7 +19743,7 @@ defines terms used throughout the rest of this major node. File: gawk.info, Node: Awk Debugging, Prev: Debugging Terms, Up: Debugging -14.1.3 Awk Debugging +15.1.3 Awk Debugging -------------------- Debugging an `awk' program has some specific aspects that are not @@ -18978,7 +19765,7 @@ commands. File: gawk.info, Node: Sample Debugging Session, Next: List of Debugger Commands, Prev: Debugging, Up: Debugger -14.2 Sample Debugging Session +15.2 Sample Debugging Session ============================= In order to illustrate the use of `gawk' as a debugger, let's look at a @@ -18994,7 +19781,7 @@ example. File: gawk.info, Node: Debugger Invocation, Next: Finding The Bug, Up: Sample Debugging Session -14.2.1 How to Start the Debugger +15.2.1 How to Start the Debugger -------------------------------- Starting the debugger is almost exactly like running `awk', except you @@ -19026,7 +19813,7 @@ code has been executed. File: gawk.info, Node: Finding The Bug, Prev: Debugger Invocation, Up: Sample Debugging Session -14.2.2 Finding the Bug +15.2.2 Finding the Bug ---------------------- Let's say that we are having a problem using (a faulty version of) @@ -19223,7 +20010,7 @@ and problem solved! File: gawk.info, Node: List of Debugger Commands, Next: Readline Support, Prev: Sample Debugging Session, Up: Debugger -14.3 Main Debugger Commands +15.3 Main Debugger Commands =========================== The `gawk' debugger command set can be divided into the following @@ -19262,7 +20049,7 @@ when just hitting <Enter>. This works for the commands `list', `next', File: gawk.info, Node: Breakpoint Control, Next: Debugger Execution Control, Up: List of Debugger Commands -14.3.1 Control of Breakpoints +15.3.1 Control of Breakpoints ----------------------------- As we saw above, the first thing you probably want to do in a debugging @@ -19357,7 +20144,7 @@ controlling breakpoints are: File: gawk.info, Node: Debugger Execution Control, Next: Viewing And Changing Data, Prev: Breakpoint Control, Up: List of Debugger Commands -14.3.2 Control of Execution +15.3.2 Control of Execution --------------------------- Now that your breakpoints are ready, you can start running the program @@ -19447,7 +20234,7 @@ execution of the program than we saw in our earlier example: File: gawk.info, Node: Viewing And Changing Data, Next: Execution Stack, Prev: Debugger Execution Control, Up: List of Debugger Commands -14.3.3 Viewing and Changing Data +15.3.3 Viewing and Changing Data -------------------------------- The commands for viewing and changing variables inside of `gawk' are: @@ -19536,7 +20323,7 @@ AWK STATEMENTS File: gawk.info, Node: Execution Stack, Next: Debugger Info, Prev: Viewing And Changing Data, Up: List of Debugger Commands -14.3.4 Dealing with the Stack +15.3.4 Dealing with the Stack ----------------------------- Whenever you run a program which contains any function calls, `gawk' @@ -19573,7 +20360,7 @@ are: File: gawk.info, Node: Debugger Info, Next: Miscellaneous Debugger Commands, Prev: Execution Stack, Up: List of Debugger Commands -14.3.5 Obtaining Information about the Program and the Debugger State +15.3.5 Obtaining Information about the Program and the Debugger State --------------------------------------------------------------------- Besides looking at the values of variables, there is often a need to get @@ -19682,7 +20469,7 @@ from a file. The commands are: File: gawk.info, Node: Miscellaneous Debugger Commands, Prev: Debugger Info, Up: List of Debugger Commands -14.3.6 Miscellaneous Commands +15.3.6 Miscellaneous Commands ----------------------------- There are a few more commands which do not fit into the previous @@ -19802,7 +20589,7 @@ categories, as follows: File: gawk.info, Node: Readline Support, Next: Limitations, Prev: List of Debugger Commands, Up: Debugger -14.4 Readline Support +15.4 Readline Support ===================== If `gawk' is compiled with the `readline' library, you can take @@ -19829,7 +20616,7 @@ Variable name completion File: gawk.info, Node: Limitations, Prev: Readline Support, Up: Debugger -14.5 Limitations and Future Plans +15.5 Limitations and Future Plans ================================= We hope you find the `gawk' debugger useful and enjoyable to work with, @@ -24884,6 +25671,7 @@ Index * - (hyphen), filenames beginning with: Options. (line 59) * - (hyphen), in bracket expressions: Bracket Expressions. (line 17) * --assign option: Options. (line 32) +* --bignum option: Options. (line 182) * --c option: Options. (line 78) * --characters-as-bytes option: Options. (line 68) * --copyright option: Options. (line 85) @@ -24900,23 +25688,23 @@ Index * --gen-pot option <1>: String Extraction. (line 6) * --gen-pot option: Options. (line 144) * --help option: Options. (line 151) -* --L option: Options. (line 263) +* --L option: Options. (line 269) * --lint option <1>: Options. (line 163) * --lint option: Command Line. (line 20) -* --lint-old option: Options. (line 263) +* --lint-old option: Options. (line 269) * --load option: Options. (line 156) * --non-decimal-data option <1>: Nondecimal Data. (line 6) -* --non-decimal-data option: Options. (line 182) +* --non-decimal-data option: Options. (line 188) * --non-decimal-data option, strtonum() function and: Nondecimal Data. (line 36) -* --optimize option: Options. (line 203) -* --posix option: Options. (line 222) -* --posix option, --traditional option and: Options. (line 241) -* --pretty-print option: Options. (line 195) +* --optimize option: Options. (line 209) +* --posix option: Options. (line 228) +* --posix option, --traditional option and: Options. (line 247) +* --pretty-print option: Options. (line 201) * --profile option <1>: Profiling. (line 12) -* --profile option: Options. (line 210) -* --re-interval option: Options. (line 247) -* --sandbox option: Options. (line 254) +* --profile option: Options. (line 216) +* --re-interval option: Options. (line 253) +* --sandbox option: Options. (line 260) * --sandbox option, disabling system() function: I/O Functions. (line 85) * --sandbox option, input redirection with getline: Getline. (line 19) @@ -24924,9 +25712,9 @@ Index (line 6) * --source option: Options. (line 114) * --traditional option: Options. (line 78) -* --traditional option, --posix option and: Options. (line 241) -* --use-lc-numeric option: Options. (line 190) -* --version option: Options. (line 268) +* --traditional option, --posix option and: Options. (line 247) +* --use-lc-numeric option: Options. (line 196) +* --version option: Options. (line 274) * --with-whiny-user-strftime configuration option: Additional Configuration Options. (line 29) * -b option: Options. (line 68) @@ -24940,20 +25728,21 @@ Index * -f option: Options. (line 25) * -F option: Options. (line 21) * -f option: Long. (line 12) -* -F option, -Ft sets FS to TAB: Options. (line 276) -* -f option, on command line: Options. (line 281) +* -F option, -Ft sets FS to TAB: Options. (line 282) +* -f option, on command line: Options. (line 287) * -g option: Options. (line 144) * -h option: Options. (line 151) * -l option: Options. (line 156) -* -N option: Options. (line 190) -* -n option: Options. (line 182) -* -O option: Options. (line 203) -* -o option: Options. (line 195) -* -P option: Options. (line 222) -* -p option: Options. (line 210) -* -r option: Options. (line 247) -* -S option: Options. (line 254) -* -V option: Options. (line 268) +* -M option: Options. (line 182) +* -N option: Options. (line 196) +* -n option: Options. (line 188) +* -O option: Options. (line 209) +* -o option: Options. (line 201) +* -P option: Options. (line 228) +* -p option: Options. (line 216) +* -r option: Options. (line 253) +* -S option: Options. (line 260) +* -V option: Options. (line 274) * -v option: Options. (line 32) * -v option, variables, assigning: Assignment Options. (line 12) * -W option: Options. (line 46) @@ -25093,7 +25882,7 @@ Index (line 67) * advanced features, data files as single record: Records. (line 175) * advanced features, fixed-width data: Constant Size. (line 9) -* advanced features, FNR/NR variables: Auto-set. (line 207) +* advanced features, FNR/NR variables: Auto-set. (line 224) * advanced features, gawk: Advanced Features. (line 6) * advanced features, gawk, network programming: TCP/IP Networking. (line 6) @@ -25128,6 +25917,8 @@ Index * and Boolean-logic operator: Boolean Ops. (line 6) * and() function (gawk): Bitwise Functions. (line 39) * ANSI: Glossary. (line 35) +* arbitrary precision: Arbitrary Precision Arithmetic. + (line 6) * archeologists: Bugs. (line 6) * ARGC/ARGV variables <1>: ARGC and ARGV. (line 6) * ARGC/ARGV variables: Auto-set. (line 11) @@ -25210,9 +26001,9 @@ Index * atan2() function: Numeric Functions. (line 11) * awf (amazingly workable formatter) program: Glossary. (line 25) * awk debugging, enabling: Options. (line 105) -* awk enabling: Options. (line 195) +* awk enabling: Options. (line 201) * awk language, POSIX version: Assignment Ops. (line 136) -* awk profiling, enabling: Options. (line 210) +* awk profiling, enabling: Options. (line 216) * awk programs <1>: Two Rules. (line 6) * awk programs <2>: Executable Scripts. (line 6) * awk programs: Getting Started. (line 12) @@ -25543,8 +26334,12 @@ Index (line 29) * configuration options, gawk: Additional Configuration Options. (line 6) +* constants, floating-point: Floating-point Constants. + (line 6) * constants, nondecimal: Nondecimal Data. (line 6) * constants, types of: Constants. (line 6) +* context, floating-point: Floating-point Context. + (line 6) * continue statement: Continue Statement. (line 6) * control statements: Statements. (line 6) * converting, case: String Functions. (line 522) @@ -25567,7 +26362,7 @@ Index * cos() function: Numeric Functions. (line 15) * counting: Wc Program. (line 6) * csh utility: Statements/Lines. (line 44) -* csh utility, POSIXLY_CORRECT environment variable: Options. (line 323) +* csh utility, POSIXLY_CORRECT environment variable: Options. (line 329) * csh utility, |& operator, comparison with: Two-way I/O. (line 44) * ctime() user-defined function: Function Example. (line 72) * currency symbols, localization: Explaining gettext. (line 103) @@ -25599,7 +26394,7 @@ Index (line 47) * dark corner, FILENAME variable <1>: Auto-set. (line 92) * dark corner, FILENAME variable: Getline Notes. (line 19) -* dark corner, FNR/NR variables: Auto-set. (line 207) +* dark corner, FNR/NR variables: Auto-set. (line 224) * dark corner, format-control characters: Control Letters. (line 18) * dark corner, FS as null string: Single Character Fields. (line 20) @@ -25736,7 +26531,7 @@ Index (line 67) * debugging awk programs: Debugger. (line 6) * debugging gawk, bug reports: Bugs. (line 9) -* decimal point character, locale specific: Options. (line 238) +* decimal point character, locale specific: Options. (line 244) * decrement operators: Increment Ops. (line 35) * default keyword: Switch Statement. (line 6) * Deifik, Scott <1>: Bugs. (line 70) @@ -25798,7 +26593,7 @@ Index * differences in awk and gawk, regular expressions: Case-sensitivity. (line 26) * differences in awk and gawk, RS/RT variables: Records. (line 167) -* differences in awk and gawk, RT variable: Auto-set. (line 196) +* differences in awk and gawk, RT variable: Auto-set. (line 213) * differences in awk and gawk, single-character fields: Single Character Fields. (line 6) * differences in awk and gawk, split() function: String Functions. @@ -25808,7 +26603,7 @@ Index * differences in awk and gawk, strtonum() function (gawk): String Functions. (line 404) * differences in awk and gawk, TEXTDOMAIN variable: User-modified. - (line 153) + (line 162) * differences in awk and gawk, trunc-mod operation: Arithmetic Ops. (line 66) * directories, changing: Sample Library. (line 6) @@ -26074,12 +26869,14 @@ Index * fixed-width data: Constant Size. (line 9) * flag variables <1>: Tee Program. (line 20) * flag variables: Boolean Ops. (line 67) +* floating-point numbers, arbitrary precision: Arbitrary Precision Arithmetic. + (line 6) * floating-point, numbers <1>: Unexpected Results. (line 6) * floating-point, numbers: Basic Data Typing. (line 21) * floating-point, numbers, AWKNUM internal type: Internals. (line 19) * FNR variable <1>: Auto-set. (line 102) * FNR variable: Records. (line 6) -* FNR variable, changing: Auto-set. (line 207) +* FNR variable, changing: Auto-set. (line 224) * for statement: For Statement. (line 6) * for statement, in arrays: Scanning an Array. (line 20) * force_number() internal function: Internals. (line 27) @@ -26115,7 +26912,7 @@ Index * FS variable, --field-separator option and: Options. (line 21) * FS variable, as null string: Single Character Fields. (line 20) -* FS variable, as TAB character: Options. (line 234) +* FS variable, as TAB character: Options. (line 240) * FS variable, changing value of: Field Separators. (line 34) * FS variable, running awk programs and: Cut Program. (line 68) * FS variable, setting from command line: Command Line Field Separator. @@ -26172,7 +26969,7 @@ Index (line 44) * functions, user-defined, next/nextfile statements and: Next Statement. (line 45) -* G-d: Acknowledgments. (line 81) +* G-d: Acknowledgments. (line 83) * Garfinkle, Scott: Contributors. (line 35) * gawk program, dynamic profiling: Profiling. (line 171) * gawk, ARGIND variable in: Other Arguments. (line 12) @@ -26201,7 +26998,7 @@ Index (line 139) * gawk, ERRNO variable in: Getline. (line 19) * gawk, escape sequences: Escape Sequences. (line 125) -* gawk, extensions, disabling: Options. (line 222) +* gawk, extensions, disabling: Options. (line 228) * gawk, features, adding: Adding Code. (line 6) * gawk, features, advanced: Advanced Features. (line 6) * gawk, fflush() function in: I/O Functions. (line 44) @@ -26254,7 +27051,7 @@ Index * gawk, regular expressions, operators: GNU Regexp Operators. (line 6) * gawk, regular expressions, precedence: Regexp Operators. (line 161) -* gawk, RT variable in <1>: Auto-set. (line 196) +* gawk, RT variable in <1>: Auto-set. (line 213) * gawk, RT variable in <2>: Getline/Variable/File. (line 10) * gawk, RT variable in <3>: Multiple Line. (line 129) @@ -26263,10 +27060,10 @@ Index * gawk, source code, obtaining: Getting. (line 6) * gawk, splitting fields and: Constant Size. (line 87) * gawk, string-translation functions: I18N Functions. (line 6) -* gawk, TEXTDOMAIN variable in: User-modified. (line 153) +* gawk, TEXTDOMAIN variable in: User-modified. (line 162) * gawk, timestamps: Time Functions. (line 6) * gawk, uses for: Preface. (line 36) -* gawk, versions of, information about, printing: Options. (line 268) +* gawk, versions of, information about, printing: Options. (line 274) * gawk, VMS version of: VMS Installation. (line 6) * gawk, word-boundary operator: GNU Regexp Operators. (line 63) @@ -26318,6 +27115,8 @@ Index * gettext() function (C library): Explaining gettext. (line 62) * gettimeofday() user-defined function: Gettimeofday Function. (line 16) +* GMP: Arbitrary Precision Arithmetic. + (line 6) * GNITS mailing list: Acknowledgments. (line 52) * GNU awk, See gawk: Preface. (line 49) * GNU Free Documentation License: GNU Free Documentation License. @@ -26357,7 +27156,7 @@ Index * help debugger command: Miscellaneous Debugger Commands. (line 68) * hexadecimal numbers: Nondecimal-numbers. (line 6) -* hexadecimal values, enabling interpretation of: Options. (line 182) +* hexadecimal values, enabling interpretation of: Options. (line 188) * histsort.awk program: History Sorting. (line 25) * Hughes, Phil: Acknowledgments. (line 43) * HUP signal: Profiling. (line 203) @@ -26371,6 +27170,8 @@ Index * i debugger command (alias for info): Debugger Info. (line 13) * id utility: Id Program. (line 6) * id.awk program: Id Program. (line 30) +* IEEE-754 format: Floating-point Representation. + (line 6) * if statement <1>: If Statement. (line 6) * if statement: Regexp Usage. (line 19) * if statement, actions, changing: Ranges. (line 25) @@ -26403,6 +27204,8 @@ Index * index() function: String Functions. (line 155) * indexing arrays: Array Intro. (line 50) * indirect function calls: Indirect Calls. (line 6) +* infinite precision: Arbitrary Precision Arithmetic. + (line 6) * info debugger command: Debugger Info. (line 13) * initialization, automatic: More Complex. (line 38) * input files: Reading Files. (line 6) @@ -26430,6 +27233,8 @@ Index * installing gawk: Installation. (line 6) * INT signal (MS-Windows): Profiling. (line 206) * int() function: Numeric Functions. (line 23) +* integer, arbitrary precision: Arbitrary Precision Integers. + (line 6) * integers: Basic Data Typing. (line 21) * integers, unsigned: Basic Data Typing. (line 30) * interacting with other programs: I/O Functions. (line 63) @@ -26467,7 +27272,7 @@ Index * internationalization: I18N Functions. (line 6) * internationalization, localization <1>: Internationalization. (line 13) -* internationalization, localization: User-modified. (line 153) +* internationalization, localization: User-modified. (line 162) * internationalization, localization, character classes: Bracket Expressions. (line 90) * internationalization, localization, gawk and: Internationalization. @@ -26507,16 +27312,19 @@ Index * Kernighan, Brian <3>: Contributors. (line 12) * Kernighan, Brian <4>: BTL. (line 6) * Kernighan, Brian <5>: Concatenation. (line 6) -* Kernighan, Brian <6>: Acknowledgments. (line 75) +* Kernighan, Brian <6>: Acknowledgments. (line 77) * Kernighan, Brian <7>: Conventions. (line 34) * Kernighan, Brian: History. (line 17) * kill command, dynamic profiling: Profiling. (line 180) * Knights, jedi: Undocumented. (line 6) +* Knuth, Donald: Arbitrary Precision Arithmetic. + (line 6) * Kwok, Conrad: Contributors. (line 35) * l debugger command (alias for list): Miscellaneous Debugger Commands. (line 74) * labels.awk program: Labels Program. (line 51) * languages, data-driven: Basic High Level. (line 83) +* Laurie, Dirk: Changing Precision. (line 6) * LC_ALL locale category: Explaining gettext. (line 120) * LC_COLLATE locale category: Explaining gettext. (line 93) * LC_CTYPE locale category: Explaining gettext. (line 97) @@ -26579,7 +27387,7 @@ Index * lint checking, empty programs: Command Line. (line 16) * lint checking, issuing warnings: Options. (line 163) * lint checking, POSIXLY_CORRECT environment variable: Options. - (line 307) + (line 313) * lint checking, undefined functions: Pass By Value/Reference. (line 88) * LINT variable: User-modified. (line 98) @@ -26592,7 +27400,7 @@ Index * loading, library: Options. (line 156) * local variables: Variable Scope. (line 6) * locale categories: Explaining gettext. (line 80) -* locale decimal point character: Options. (line 238) +* locale decimal point character: Options. (line 244) * locale, definition of: Locales. (line 6) * localization: I18N and L10N. (line 6) * localization, See internationalization, localization: I18N and L10N. @@ -26643,7 +27451,11 @@ Index * mktime() function (gawk): Time Functions. (line 24) * modifiers, in format specifiers: Format Modifiers. (line 6) * monetary information, localization: Explaining gettext. (line 103) +* MPFR: Arbitrary Precision Arithmetic. + (line 6) * msgfmt utility: I18N Example. (line 62) +* multiple precision: Arbitrary Precision Arithmetic. + (line 6) * n debugger command (alias for next): Debugger Execution Control. (line 43) * names, arrays/variables <1>: Library Names. (line 6) @@ -26660,7 +27472,7 @@ Index * networks, programming: TCP/IP Networking. (line 6) * networks, support for: Special Network. (line 6) * newlines <1>: Boolean Ops. (line 67) -* newlines <2>: Options. (line 228) +* newlines <2>: Options. (line 234) * newlines: Statements/Lines. (line 6) * newlines, as field separators: Default Field Splitting. (line 6) @@ -26699,7 +27511,7 @@ Index * not Boolean-logic operator: Boolean Ops. (line 6) * NR variable <1>: Auto-set. (line 118) * NR variable: Records. (line 6) -* NR variable, changing: Auto-set. (line 207) +* NR variable, changing: Auto-set. (line 224) * null strings <1>: Basic Data Typing. (line 50) * null strings <2>: Truth Values. (line 6) * null strings <3>: Regexp Field Splitting. @@ -26740,7 +27552,7 @@ Index * oawk utility: Names. (line 17) * obsolete features: Obsolete. (line 6) * octal numbers: Nondecimal-numbers. (line 6) -* octal values, enabling interpretation of: Options. (line 182) +* octal values, enabling interpretation of: Options. (line 188) * OFMT variable <1>: User-modified. (line 115) * OFMT variable <2>: Conversion. (line 55) * OFMT variable: OFMT. (line 15) @@ -26885,7 +27697,7 @@ Index * portability, NF variable, decrementing: Changing Fields. (line 115) * portability, operators: Increment Ops. (line 61) * portability, operators, not in POSIX awk: Precedence. (line 98) -* portability, POSIXLY_CORRECT environment variable: Options. (line 328) +* portability, POSIXLY_CORRECT environment variable: Options. (line 334) * portability, substr() function: String Functions. (line 512) * portable object files <1>: Translator i18n. (line 6) * portable object files: Explaining gettext. (line 36) @@ -26935,11 +27747,13 @@ Index * POSIX awk, regular expressions and: Regexp Operators. (line 161) * POSIX awk, timestamps and: Time Functions. (line 6) * POSIX awk, | I/O operator and: Getline/Pipe. (line 52) -* POSIX mode: Options. (line 222) +* POSIX mode: Options. (line 228) * POSIX, awk and: Preface. (line 23) * POSIX, gawk extensions not included in: POSIX/GNU. (line 6) * POSIX, programs, implementing in awk: Clones. (line 6) -* POSIXLY_CORRECT environment variable: Options. (line 307) +* POSIXLY_CORRECT environment variable: Options. (line 313) +* PREC variable <1>: Setting Precision. (line 6) +* PREC variable: User-modified. (line 134) * precedence <1>: Precedence. (line 6) * precedence: Increment Ops. (line 61) * precedence, regexp operators: Regexp Operators. (line 156) @@ -27048,7 +27862,7 @@ Index * readable data files, checking: File Checking. (line 6) * readable.awk program: File Checking. (line 11) * recipe for a programming language: History. (line 6) -* record separators <1>: User-modified. (line 134) +* record separators <1>: User-modified. (line 143) * record separators: Records. (line 14) * record separators, changing: Records. (line 81) * record separators, regular expressions as: Records. (line 112) @@ -27096,7 +27910,7 @@ Index (line 59) * regular expressions, gawk, command-line options: GNU Regexp Operators. (line 70) -* regular expressions, interval expressions and: Options. (line 247) +* regular expressions, interval expressions and: Options. (line 253) * regular expressions, leftmost longest match: Leftmost Longest. (line 6) * regular expressions, operators <1>: Regexp Operators. (line 6) @@ -27130,7 +27944,7 @@ Index * right angle bracket (>), >> operator (I/O): Redirection. (line 50) * right shift, bitwise: Bitwise Functions. (line 32) * Ritchie, Dennis: Basic Data Typing. (line 74) -* RLENGTH variable: Auto-set. (line 183) +* RLENGTH variable: Auto-set. (line 200) * RLENGTH variable, match() function and: String Functions. (line 223) * Robbins, Arnold <1>: Future Extensions. (line 6) * Robbins, Arnold <2>: Bugs. (line 32) @@ -27141,23 +27955,27 @@ Index * Robbins, Arnold: Command Line Field Separator. (line 80) * Robbins, Bill: Getline/Pipe. (line 36) -* Robbins, Harry: Acknowledgments. (line 81) -* Robbins, Jean: Acknowledgments. (line 81) +* Robbins, Harry: Acknowledgments. (line 83) +* Robbins, Jean: Acknowledgments. (line 83) * Robbins, Miriam <1>: Passwd Functions. (line 90) * Robbins, Miriam <2>: Getline/Pipe. (line 36) -* Robbins, Miriam: Acknowledgments. (line 81) +* Robbins, Miriam: Acknowledgments. (line 83) * Robinson, Will: Dynamic Extensions. (line 6) * robot, the: Dynamic Extensions. (line 6) * Rommel, Kai Uwe: Contributors. (line 43) * round() user-defined function: Round Function. (line 16) +* rounding mode, floating-point: Rounding Mode. (line 6) * rounding numbers: Round Function. (line 6) -* RS variable <1>: User-modified. (line 134) +* ROUNDMODE variable <1>: Setting Rounding Mode. + (line 6) +* ROUNDMODE variable: User-modified. (line 138) +* RS variable <1>: User-modified. (line 143) * RS variable: Records. (line 20) * RS variable, multiline records and: Multiple Line. (line 17) * rshift() function (gawk): Bitwise Functions. (line 51) -* RSTART variable: Auto-set. (line 189) +* RSTART variable: Auto-set. (line 206) * RSTART variable, match() function and: String Functions. (line 223) -* RT variable <1>: Auto-set. (line 196) +* RT variable <1>: Auto-set. (line 213) * RT variable <2>: Getline/Variable/File. (line 10) * RT variable <3>: Multiple Line. (line 129) @@ -27170,7 +27988,7 @@ Index * rvalues/lvalues: Assignment Ops. (line 32) * s debugger command (alias for step): Debugger Execution Control. (line 68) -* sandbox mode: Options. (line 254) +* sandbox mode: Options. (line 260) * scalar values: Basic Data Typing. (line 13) * Schorr, Andrew: Acknowledgments. (line 60) * Schreiber, Bert: Acknowledgments. (line 38) @@ -27200,11 +28018,11 @@ Index * separators, field, FIELDWIDTHS variable and: User-modified. (line 35) * separators, field, FPAT variable and: User-modified. (line 45) * separators, field, POSIX and: Fields. (line 6) -* separators, for records <1>: User-modified. (line 134) +* separators, for records <1>: User-modified. (line 143) * separators, for records: Records. (line 14) * separators, for records, regular expressions as: Records. (line 112) * separators, for statements in actions: Action Overview. (line 19) -* separators, subscript: User-modified. (line 147) +* separators, subscript: User-modified. (line 156) * set debugger command: Viewing And Changing Data. (line 59) * shells, piping commands into: Redirection. (line 143) @@ -27337,7 +28155,7 @@ Index (line 43) * sub() function, arguments of: String Functions. (line 462) * sub() function, escape processing: Gory Details. (line 6) -* subscript separators: User-modified. (line 147) +* subscript separators: User-modified. (line 156) * subscripts in arrays, multidimensional: Multi-dimensional. (line 10) * subscripts in arrays, multidimensional, scanning: Multi-scanning. (line 11) @@ -27345,7 +28163,7 @@ Index (line 6) * subscripts in arrays, uninitialized variables as: Uninitialized Subscripts. (line 6) -* SUBSEP variable: User-modified. (line 147) +* SUBSEP variable: User-modified. (line 156) * SUBSEP variable, multidimensional arrays: Multi-dimensional. (line 16) * substr() function: String Functions. (line 481) @@ -27378,7 +28196,7 @@ Index * text, printing: Print. (line 22) * text, printing, unduplicated lines of: Uniq Program. (line 6) * TEXTDOMAIN variable <1>: Programmer i18n. (line 9) -* TEXTDOMAIN variable: User-modified. (line 153) +* TEXTDOMAIN variable: User-modified. (line 162) * TEXTDOMAIN variable, BEGIN pattern and: Programmer i18n. (line 60) * TEXTDOMAIN variable, portability and: I18N Portability. (line 20) * textdomain() function (C library): Explaining gettext. (line 27) @@ -27406,7 +28224,7 @@ Index * trace debugger command: Miscellaneous Debugger Commands. (line 110) * translate.awk program: Translate Program. (line 55) -* troubleshooting, --non-decimal-data option: Options. (line 182) +* troubleshooting, --non-decimal-data option: Options. (line 188) * troubleshooting, == operator: Comparison Operators. (line 37) * troubleshooting, awk uses FS not IFS: Field Separators. (line 29) @@ -27551,7 +28369,7 @@ Index * whitespace, as field separators: Default Field Splitting. (line 6) * whitespace, functions, calling: Calling Built-in. (line 10) -* whitespace, newlines as: Options. (line 228) +* whitespace, newlines as: Options. (line 234) * Williams, Kent: Contributors. (line 35) * Woehlke, Matthew: Contributors. (line 79) * Woods, John: Contributors. (line 28) @@ -27607,419 +28425,440 @@ Index Tag Table: Node: Top1352 -Node: Foreword30423 -Node: Preface34768 -Ref: Preface-Footnote-137821 -Ref: Preface-Footnote-237927 -Node: History38159 -Node: Names40550 -Ref: Names-Footnote-142027 -Node: This Manual42099 -Ref: This Manual-Footnote-147037 -Node: Conventions47137 -Node: Manual History49271 -Ref: Manual History-Footnote-152541 -Ref: Manual History-Footnote-252582 -Node: How To Contribute52656 -Node: Acknowledgments53800 -Node: Getting Started58131 -Node: Running gawk60510 -Node: One-shot61696 -Node: Read Terminal62921 -Ref: Read Terminal-Footnote-164571 -Ref: Read Terminal-Footnote-264847 -Node: Long65018 -Node: Executable Scripts66394 -Ref: Executable Scripts-Footnote-168263 -Ref: Executable Scripts-Footnote-268365 -Node: Comments68912 -Node: Quoting71379 -Node: DOS Quoting76002 -Node: Sample Data Files76677 -Node: Very Simple79709 -Node: Two Rules84308 -Node: More Complex86455 -Ref: More Complex-Footnote-189385 -Node: Statements/Lines89470 -Ref: Statements/Lines-Footnote-193932 -Node: Other Features94197 -Node: When95125 -Node: Invoking Gawk97272 -Node: Command Line98657 -Node: Options99440 -Ref: Options-Footnote-1113585 -Node: Other Arguments113610 -Node: Naming Standard Input116268 -Node: Environment Variables117362 -Node: AWKPATH Variable117806 -Ref: AWKPATH Variable-Footnote-1120403 -Node: Other Environment Variables120663 -Node: Exit Status123155 -Node: Include Files123830 -Node: Obsolete127315 -Node: Undocumented128001 -Node: Regexp128242 -Node: Regexp Usage129631 -Node: Escape Sequences131657 -Node: Regexp Operators137420 -Ref: Regexp Operators-Footnote-1144800 -Ref: Regexp Operators-Footnote-2144947 -Node: Bracket Expressions145045 -Ref: table-char-classes146935 -Node: GNU Regexp Operators149458 -Node: Case-sensitivity153181 -Ref: Case-sensitivity-Footnote-1156149 -Ref: Case-sensitivity-Footnote-2156384 -Node: Leftmost Longest156492 -Node: Computed Regexps157693 -Node: Reading Files161103 -Node: Records163107 -Ref: Records-Footnote-1171781 -Node: Fields171818 -Ref: Fields-Footnote-1174851 -Node: Nonconstant Fields174937 -Node: Changing Fields177139 -Node: Field Separators183120 -Node: Default Field Splitting185749 -Node: Regexp Field Splitting186866 -Node: Single Character Fields190208 -Node: Command Line Field Separator191267 -Node: Field Splitting Summary194708 -Ref: Field Splitting Summary-Footnote-1197900 -Node: Constant Size198001 -Node: Splitting By Content202585 -Ref: Splitting By Content-Footnote-1206311 -Node: Multiple Line206351 -Ref: Multiple Line-Footnote-1212198 -Node: Getline212377 -Node: Plain Getline214593 -Node: Getline/Variable216682 -Node: Getline/File217823 -Node: Getline/Variable/File219145 -Ref: Getline/Variable/File-Footnote-1220744 -Node: Getline/Pipe220831 -Node: Getline/Variable/Pipe223391 -Node: Getline/Coprocess224498 -Node: Getline/Variable/Coprocess225741 -Node: Getline Notes226455 -Node: Getline Summary228397 -Ref: table-getline-variants228740 -Node: Read Timeout229596 -Ref: Read Timeout-Footnote-1233341 -Node: Command line directories233398 -Node: Printing234028 -Node: Print235659 -Node: Print Examples236996 -Node: Output Separators239780 -Node: OFMT241540 -Node: Printf242898 -Node: Basic Printf243804 -Node: Control Letters245343 -Node: Format Modifiers249155 -Node: Printf Examples255164 -Node: Redirection257879 -Node: Special Files264863 -Node: Special FD265396 -Ref: Special FD-Footnote-1269021 -Node: Special Network269095 -Node: Special Caveats269945 -Node: Close Files And Pipes270741 -Ref: Close Files And Pipes-Footnote-1277764 -Ref: Close Files And Pipes-Footnote-2277912 -Node: Expressions278062 -Node: Values279194 -Node: Constants279870 -Node: Scalar Constants280550 -Ref: Scalar Constants-Footnote-1281409 -Node: Nondecimal-numbers281591 -Node: Regexp Constants284650 -Node: Using Constant Regexps285125 -Node: Variables288180 -Node: Using Variables288835 -Node: Assignment Options290559 -Node: Conversion292431 -Ref: table-locale-affects297807 -Ref: Conversion-Footnote-1298431 -Node: All Operators298540 -Node: Arithmetic Ops299170 -Node: Concatenation301675 -Ref: Concatenation-Footnote-1304468 -Node: Assignment Ops304588 -Ref: table-assign-ops309576 -Node: Increment Ops310984 -Node: Truth Values and Conditions314454 -Node: Truth Values315537 -Node: Typing and Comparison316586 -Node: Variable Typing317375 -Ref: Variable Typing-Footnote-1321272 -Node: Comparison Operators321394 -Ref: table-relational-ops321804 -Node: POSIX String Comparison325353 -Ref: POSIX String Comparison-Footnote-1326309 -Node: Boolean Ops326447 -Ref: Boolean Ops-Footnote-1330525 -Node: Conditional Exp330616 -Node: Function Calls332348 -Node: Precedence335942 -Node: Locales339611 -Node: Patterns and Actions340700 -Node: Pattern Overview341754 -Node: Regexp Patterns343423 -Node: Expression Patterns343966 -Node: Ranges347651 -Node: BEGIN/END350617 -Node: Using BEGIN/END351379 -Ref: Using BEGIN/END-Footnote-1354110 -Node: I/O And BEGIN/END354216 -Node: BEGINFILE/ENDFILE356498 -Node: Empty359391 -Node: Using Shell Variables359707 -Node: Action Overview361992 -Node: Statements364349 -Node: If Statement366203 -Node: While Statement367702 -Node: Do Statement369746 -Node: For Statement370902 -Node: Switch Statement374054 -Node: Break Statement376151 -Node: Continue Statement378141 -Node: Next Statement379934 -Node: Nextfile Statement382324 -Node: Exit Statement384869 -Node: Built-in Variables387285 -Node: User-modified388380 -Ref: User-modified-Footnote-1396406 -Node: Auto-set396468 -Ref: Auto-set-Footnote-1405759 -Node: ARGC and ARGV405964 -Node: Arrays409815 -Node: Array Basics411320 -Node: Array Intro412146 -Node: Reference to Elements416464 -Node: Assigning Elements418734 -Node: Array Example419225 -Node: Scanning an Array420957 -Node: Controlling Scanning423271 -Ref: Controlling Scanning-Footnote-1428204 -Node: Delete428520 -Ref: Delete-Footnote-1430955 -Node: Numeric Array Subscripts431012 -Node: Uninitialized Subscripts433195 -Node: Multi-dimensional434823 -Node: Multi-scanning437917 -Node: Arrays of Arrays439508 -Node: Functions444153 -Node: Built-in444975 -Node: Calling Built-in446053 -Node: Numeric Functions448041 -Ref: Numeric Functions-Footnote-1451873 -Ref: Numeric Functions-Footnote-2452230 -Ref: Numeric Functions-Footnote-3452278 -Node: String Functions452547 -Ref: String Functions-Footnote-1476044 -Ref: String Functions-Footnote-2476173 -Ref: String Functions-Footnote-3476421 -Node: Gory Details476508 -Ref: table-sub-escapes478187 -Ref: table-sub-posix-92479541 -Ref: table-sub-proposed480884 -Ref: table-posix-sub482234 -Ref: table-gensub-escapes483780 -Ref: Gory Details-Footnote-1484987 -Ref: Gory Details-Footnote-2485038 -Node: I/O Functions485189 -Ref: I/O Functions-Footnote-1491844 -Node: Time Functions491991 -Ref: Time Functions-Footnote-1502883 -Ref: Time Functions-Footnote-2502951 -Ref: Time Functions-Footnote-3503109 -Ref: Time Functions-Footnote-4503220 -Ref: Time Functions-Footnote-5503332 -Ref: Time Functions-Footnote-6503559 -Node: Bitwise Functions503825 -Ref: table-bitwise-ops504383 -Ref: Bitwise Functions-Footnote-1508543 -Node: Type Functions508727 -Node: I18N Functions509197 -Node: User-defined510824 -Node: Definition Syntax511628 -Ref: Definition Syntax-Footnote-1516538 -Node: Function Example516607 -Node: Function Caveats519201 -Node: Calling A Function519622 -Node: Variable Scope520737 -Node: Pass By Value/Reference522712 -Node: Return Statement526152 -Node: Dynamic Typing529133 -Node: Indirect Calls529868 -Node: Internationalization539553 -Node: I18N and L10N540979 -Node: Explaining gettext541665 -Ref: Explaining gettext-Footnote-1546731 -Ref: Explaining gettext-Footnote-2546915 -Node: Programmer i18n547080 -Node: Translator i18n551280 -Node: String Extraction552073 -Ref: String Extraction-Footnote-1553034 -Node: Printf Ordering553120 -Ref: Printf Ordering-Footnote-1555904 -Node: I18N Portability555968 -Ref: I18N Portability-Footnote-1558417 -Node: I18N Example558480 -Ref: I18N Example-Footnote-1561115 -Node: Gawk I18N561187 -Node: Advanced Features561804 -Node: Nondecimal Data563317 -Node: Array Sorting564900 -Node: Controlling Array Traversal565597 -Node: Array Sorting Functions573834 -Ref: Array Sorting Functions-Footnote-1577508 -Ref: Array Sorting Functions-Footnote-2577601 -Node: Two-way I/O577795 -Ref: Two-way I/O-Footnote-1583227 -Node: TCP/IP Networking583297 -Node: Profiling586141 -Node: Library Functions593595 -Ref: Library Functions-Footnote-1596602 -Node: Library Names596773 -Ref: Library Names-Footnote-1600244 -Ref: Library Names-Footnote-2600464 -Node: General Functions600550 -Node: Strtonum Function601503 -Node: Assert Function604433 -Node: Round Function607759 -Node: Cliff Random Function609302 -Node: Ordinal Functions610318 -Ref: Ordinal Functions-Footnote-1613388 -Ref: Ordinal Functions-Footnote-2613640 -Node: Join Function613849 -Ref: Join Function-Footnote-1615620 -Node: Gettimeofday Function615820 -Node: Data File Management619535 -Node: Filetrans Function620167 -Node: Rewind Function624306 -Node: File Checking625693 -Node: Empty Files626787 -Node: Ignoring Assigns629017 -Node: Getopt Function630570 -Ref: Getopt Function-Footnote-1641874 -Node: Passwd Functions642077 -Ref: Passwd Functions-Footnote-1651052 -Node: Group Functions651140 -Node: Walking Arrays659224 -Node: Sample Programs660793 -Node: Running Examples661458 -Node: Clones662186 -Node: Cut Program663410 -Node: Egrep Program673255 -Ref: Egrep Program-Footnote-1681028 -Node: Id Program681138 -Node: Split Program684754 -Ref: Split Program-Footnote-1688273 -Node: Tee Program688401 -Node: Uniq Program691204 -Node: Wc Program698633 -Ref: Wc Program-Footnote-1702899 -Ref: Wc Program-Footnote-2703099 -Node: Miscellaneous Programs703191 -Node: Dupword Program704379 -Node: Alarm Program706410 -Node: Translate Program711159 -Ref: Translate Program-Footnote-1715546 -Ref: Translate Program-Footnote-2715774 -Node: Labels Program715908 -Ref: Labels Program-Footnote-1719279 -Node: Word Sorting719363 -Node: History Sorting723247 -Node: Extract Program725086 -Ref: Extract Program-Footnote-1732569 -Node: Simple Sed732697 -Node: Igawk Program735759 -Ref: Igawk Program-Footnote-1750916 -Ref: Igawk Program-Footnote-2751117 -Node: Anagram Program751255 -Node: Signature Program754323 -Node: Debugger755423 -Node: Debugging756375 -Node: Debugging Concepts756808 -Node: Debugging Terms758664 -Node: Awk Debugging761261 -Node: Sample Debugging Session762153 -Node: Debugger Invocation762673 -Node: Finding The Bug764002 -Node: List of Debugger Commands770490 -Node: Breakpoint Control771824 -Node: Debugger Execution Control775488 -Node: Viewing And Changing Data778848 -Node: Execution Stack782204 -Node: Debugger Info783671 -Node: Miscellaneous Debugger Commands787652 -Node: Readline Support793097 -Node: Limitations793928 -Node: Language History796180 -Node: V7/SVR3.1797692 -Node: SVR4800013 -Node: POSIX801455 -Node: BTL802463 -Node: POSIX/GNU803197 -Node: Common Extensions808348 -Node: Ranges and Locales809455 -Ref: Ranges and Locales-Footnote-1814059 -Node: Contributors814280 -Node: Installation818541 -Node: Gawk Distribution819435 -Node: Getting819919 -Node: Extracting820745 -Node: Distribution contents822437 -Node: Unix Installation827659 -Node: Quick Installation828276 -Node: Additional Configuration Options830238 -Node: Configuration Philosophy831715 -Node: Non-Unix Installation834057 -Node: PC Installation834515 -Node: PC Binary Installation835814 -Node: PC Compiling837662 -Node: PC Testing840606 -Node: PC Using841782 -Node: Cygwin845967 -Node: MSYS846967 -Node: VMS Installation847481 -Node: VMS Compilation848084 -Ref: VMS Compilation-Footnote-1849091 -Node: VMS Installation Details849149 -Node: VMS Running850784 -Node: VMS Old Gawk852391 -Node: Bugs852865 -Node: Other Versions856717 -Node: Notes862032 -Node: Compatibility Mode862724 -Node: Additions863507 -Node: Accessing The Source864319 -Node: Adding Code865744 -Node: New Ports871711 -Node: Dynamic Extensions875824 -Node: Internals877264 -Node: Plugin License885783 -Node: Loading Extensions886421 -Node: Sample Library888231 -Node: Internal File Description888921 -Node: Internal File Ops892636 -Ref: Internal File Ops-Footnote-1897360 -Node: Using Internal File Ops897500 -Node: Future Extensions899877 -Node: Basic Concepts902381 -Node: Basic High Level903138 -Ref: Basic High Level-Footnote-1907173 -Node: Basic Data Typing907358 -Node: Floating Point Issues911883 -Node: String Conversion Precision912966 -Ref: String Conversion Precision-Footnote-1914666 -Node: Unexpected Results914775 -Node: POSIX Floating Point Problems916601 -Ref: POSIX Floating Point Problems-Footnote-1920306 -Node: Glossary920344 -Node: Copying945320 -Node: GNU Free Documentation License982877 -Node: Index1008014 +Node: Foreword31559 +Node: Preface35904 +Ref: Preface-Footnote-138957 +Ref: Preface-Footnote-239063 +Node: History39295 +Node: Names41686 +Ref: Names-Footnote-143163 +Node: This Manual43235 +Ref: This Manual-Footnote-148173 +Node: Conventions48273 +Node: Manual History50407 +Ref: Manual History-Footnote-153677 +Ref: Manual History-Footnote-253718 +Node: How To Contribute53792 +Node: Acknowledgments54936 +Node: Getting Started59432 +Node: Running gawk61811 +Node: One-shot62997 +Node: Read Terminal64222 +Ref: Read Terminal-Footnote-165872 +Ref: Read Terminal-Footnote-266148 +Node: Long66319 +Node: Executable Scripts67695 +Ref: Executable Scripts-Footnote-169564 +Ref: Executable Scripts-Footnote-269666 +Node: Comments70213 +Node: Quoting72680 +Node: DOS Quoting77303 +Node: Sample Data Files77978 +Node: Very Simple81010 +Node: Two Rules85609 +Node: More Complex87756 +Ref: More Complex-Footnote-190686 +Node: Statements/Lines90771 +Ref: Statements/Lines-Footnote-195233 +Node: Other Features95498 +Node: When96426 +Node: Invoking Gawk98573 +Node: Command Line99958 +Node: Options100741 +Ref: Options-Footnote-1115098 +Node: Other Arguments115123 +Node: Naming Standard Input117781 +Node: Environment Variables118875 +Node: AWKPATH Variable119319 +Ref: AWKPATH Variable-Footnote-1121916 +Node: Other Environment Variables122176 +Node: Exit Status124668 +Node: Include Files125343 +Node: Obsolete128828 +Node: Undocumented129514 +Node: Regexp129755 +Node: Regexp Usage131144 +Node: Escape Sequences133170 +Node: Regexp Operators138933 +Ref: Regexp Operators-Footnote-1146313 +Ref: Regexp Operators-Footnote-2146460 +Node: Bracket Expressions146558 +Ref: table-char-classes148448 +Node: GNU Regexp Operators150971 +Node: Case-sensitivity154694 +Ref: Case-sensitivity-Footnote-1157662 +Ref: Case-sensitivity-Footnote-2157897 +Node: Leftmost Longest158005 +Node: Computed Regexps159206 +Node: Reading Files162616 +Node: Records164620 +Ref: Records-Footnote-1173294 +Node: Fields173331 +Ref: Fields-Footnote-1176364 +Node: Nonconstant Fields176450 +Node: Changing Fields178652 +Node: Field Separators184633 +Node: Default Field Splitting187262 +Node: Regexp Field Splitting188379 +Node: Single Character Fields191721 +Node: Command Line Field Separator192780 +Node: Field Splitting Summary196221 +Ref: Field Splitting Summary-Footnote-1199413 +Node: Constant Size199514 +Node: Splitting By Content204098 +Ref: Splitting By Content-Footnote-1207824 +Node: Multiple Line207864 +Ref: Multiple Line-Footnote-1213711 +Node: Getline213890 +Node: Plain Getline216106 +Node: Getline/Variable218195 +Node: Getline/File219336 +Node: Getline/Variable/File220658 +Ref: Getline/Variable/File-Footnote-1222257 +Node: Getline/Pipe222344 +Node: Getline/Variable/Pipe224904 +Node: Getline/Coprocess226011 +Node: Getline/Variable/Coprocess227254 +Node: Getline Notes227968 +Node: Getline Summary229910 +Ref: table-getline-variants230253 +Node: Read Timeout231109 +Ref: Read Timeout-Footnote-1234854 +Node: Command line directories234911 +Node: Printing235541 +Node: Print237172 +Node: Print Examples238509 +Node: Output Separators241293 +Node: OFMT243053 +Node: Printf244411 +Node: Basic Printf245317 +Node: Control Letters246856 +Node: Format Modifiers250668 +Node: Printf Examples256677 +Node: Redirection259392 +Node: Special Files266376 +Node: Special FD266909 +Ref: Special FD-Footnote-1270534 +Node: Special Network270608 +Node: Special Caveats271458 +Node: Close Files And Pipes272254 +Ref: Close Files And Pipes-Footnote-1279277 +Ref: Close Files And Pipes-Footnote-2279425 +Node: Expressions279575 +Node: Values280707 +Node: Constants281383 +Node: Scalar Constants282063 +Ref: Scalar Constants-Footnote-1282922 +Node: Nondecimal-numbers283104 +Node: Regexp Constants286163 +Node: Using Constant Regexps286638 +Node: Variables289693 +Node: Using Variables290348 +Node: Assignment Options292072 +Node: Conversion293944 +Ref: table-locale-affects299320 +Ref: Conversion-Footnote-1299944 +Node: All Operators300053 +Node: Arithmetic Ops300683 +Node: Concatenation303188 +Ref: Concatenation-Footnote-1305981 +Node: Assignment Ops306101 +Ref: table-assign-ops311089 +Node: Increment Ops312497 +Node: Truth Values and Conditions315967 +Node: Truth Values317050 +Node: Typing and Comparison318099 +Node: Variable Typing318888 +Ref: Variable Typing-Footnote-1322785 +Node: Comparison Operators322907 +Ref: table-relational-ops323317 +Node: POSIX String Comparison326866 +Ref: POSIX String Comparison-Footnote-1327822 +Node: Boolean Ops327960 +Ref: Boolean Ops-Footnote-1332038 +Node: Conditional Exp332129 +Node: Function Calls333861 +Node: Precedence337455 +Node: Locales341124 +Node: Patterns and Actions342213 +Node: Pattern Overview343267 +Node: Regexp Patterns344936 +Node: Expression Patterns345479 +Node: Ranges349164 +Node: BEGIN/END352130 +Node: Using BEGIN/END352892 +Ref: Using BEGIN/END-Footnote-1355623 +Node: I/O And BEGIN/END355729 +Node: BEGINFILE/ENDFILE358011 +Node: Empty360904 +Node: Using Shell Variables361220 +Node: Action Overview363505 +Node: Statements365862 +Node: If Statement367716 +Node: While Statement369215 +Node: Do Statement371259 +Node: For Statement372415 +Node: Switch Statement375567 +Node: Break Statement377664 +Node: Continue Statement379654 +Node: Next Statement381447 +Node: Nextfile Statement383837 +Node: Exit Statement386382 +Node: Built-in Variables388798 +Node: User-modified389893 +Ref: User-modified-Footnote-1398248 +Node: Auto-set398310 +Ref: Auto-set-Footnote-1408156 +Node: ARGC and ARGV408361 +Node: Arrays412212 +Node: Array Basics413717 +Node: Array Intro414543 +Node: Reference to Elements418861 +Node: Assigning Elements421131 +Node: Array Example421622 +Node: Scanning an Array423354 +Node: Controlling Scanning425668 +Ref: Controlling Scanning-Footnote-1430601 +Node: Delete430917 +Ref: Delete-Footnote-1433352 +Node: Numeric Array Subscripts433409 +Node: Uninitialized Subscripts435592 +Node: Multi-dimensional437220 +Node: Multi-scanning440314 +Node: Arrays of Arrays441905 +Node: Functions446550 +Node: Built-in447372 +Node: Calling Built-in448450 +Node: Numeric Functions450438 +Ref: Numeric Functions-Footnote-1454270 +Ref: Numeric Functions-Footnote-2454627 +Ref: Numeric Functions-Footnote-3454675 +Node: String Functions454944 +Ref: String Functions-Footnote-1478441 +Ref: String Functions-Footnote-2478570 +Ref: String Functions-Footnote-3478818 +Node: Gory Details478905 +Ref: table-sub-escapes480584 +Ref: table-sub-posix-92481938 +Ref: table-sub-proposed483281 +Ref: table-posix-sub484631 +Ref: table-gensub-escapes486177 +Ref: Gory Details-Footnote-1487384 +Ref: Gory Details-Footnote-2487435 +Node: I/O Functions487586 +Ref: I/O Functions-Footnote-1494241 +Node: Time Functions494388 +Ref: Time Functions-Footnote-1505280 +Ref: Time Functions-Footnote-2505348 +Ref: Time Functions-Footnote-3505506 +Ref: Time Functions-Footnote-4505617 +Ref: Time Functions-Footnote-5505729 +Ref: Time Functions-Footnote-6505956 +Node: Bitwise Functions506222 +Ref: table-bitwise-ops506780 +Ref: Bitwise Functions-Footnote-1510940 +Node: Type Functions511124 +Node: I18N Functions511594 +Node: User-defined513221 +Node: Definition Syntax514025 +Ref: Definition Syntax-Footnote-1518935 +Node: Function Example519004 +Node: Function Caveats521598 +Node: Calling A Function522019 +Node: Variable Scope523134 +Node: Pass By Value/Reference525109 +Node: Return Statement528549 +Node: Dynamic Typing531530 +Node: Indirect Calls532265 +Node: Internationalization541950 +Node: I18N and L10N543389 +Node: Explaining gettext544075 +Ref: Explaining gettext-Footnote-1549141 +Ref: Explaining gettext-Footnote-2549325 +Node: Programmer i18n549490 +Node: Translator i18n553690 +Node: String Extraction554483 +Ref: String Extraction-Footnote-1555444 +Node: Printf Ordering555530 +Ref: Printf Ordering-Footnote-1558314 +Node: I18N Portability558378 +Ref: I18N Portability-Footnote-1560827 +Node: I18N Example560890 +Ref: I18N Example-Footnote-1563525 +Node: Gawk I18N563597 +Node: Arbitrary Precision Arithmetic564214 +Ref: Arbitrary Precision Arithmetic-Footnote-1567089 +Node: Floating-point Programming567237 +Node: Floating-point Representation572507 +Node: Floating-point Context573611 +Ref: table-ieee-formats574446 +Node: Rounding Mode575816 +Ref: table-rounding-modes576443 +Ref: Rounding Mode-Footnote-1579566 +Node: Arbitrary Precision Floats579747 +Ref: Arbitrary Precision Floats-Footnote-1581788 +Node: Setting Precision582099 +Node: Setting Rounding Mode584857 +Node: Floating-point Constants585774 +Node: Changing Precision587193 +Ref: Changing Precision-Footnote-1588593 +Node: Exact Arithmetic588766 +Node: Integer Programming591779 +Node: Arbitrary Precision Integers593559 +Ref: Arbitrary Precision Integers-Footnote-1596583 +Node: MPFR and GMP Libraries596729 +Node: Advanced Features597114 +Node: Nondecimal Data598637 +Node: Array Sorting600220 +Node: Controlling Array Traversal600917 +Node: Array Sorting Functions609154 +Ref: Array Sorting Functions-Footnote-1612828 +Ref: Array Sorting Functions-Footnote-2612921 +Node: Two-way I/O613115 +Ref: Two-way I/O-Footnote-1618547 +Node: TCP/IP Networking618617 +Node: Profiling621461 +Node: Library Functions628915 +Ref: Library Functions-Footnote-1631922 +Node: Library Names632093 +Ref: Library Names-Footnote-1635564 +Ref: Library Names-Footnote-2635784 +Node: General Functions635870 +Node: Strtonum Function636823 +Node: Assert Function639753 +Node: Round Function643079 +Node: Cliff Random Function644622 +Node: Ordinal Functions645638 +Ref: Ordinal Functions-Footnote-1648708 +Ref: Ordinal Functions-Footnote-2648960 +Node: Join Function649169 +Ref: Join Function-Footnote-1650940 +Node: Gettimeofday Function651140 +Node: Data File Management654855 +Node: Filetrans Function655487 +Node: Rewind Function659626 +Node: File Checking661013 +Node: Empty Files662107 +Node: Ignoring Assigns664337 +Node: Getopt Function665890 +Ref: Getopt Function-Footnote-1677194 +Node: Passwd Functions677397 +Ref: Passwd Functions-Footnote-1686372 +Node: Group Functions686460 +Node: Walking Arrays694544 +Node: Sample Programs696113 +Node: Running Examples696778 +Node: Clones697506 +Node: Cut Program698730 +Node: Egrep Program708575 +Ref: Egrep Program-Footnote-1716348 +Node: Id Program716458 +Node: Split Program720074 +Ref: Split Program-Footnote-1723593 +Node: Tee Program723721 +Node: Uniq Program726524 +Node: Wc Program733953 +Ref: Wc Program-Footnote-1738219 +Ref: Wc Program-Footnote-2738419 +Node: Miscellaneous Programs738511 +Node: Dupword Program739699 +Node: Alarm Program741730 +Node: Translate Program746479 +Ref: Translate Program-Footnote-1750866 +Ref: Translate Program-Footnote-2751094 +Node: Labels Program751228 +Ref: Labels Program-Footnote-1754599 +Node: Word Sorting754683 +Node: History Sorting758567 +Node: Extract Program760406 +Ref: Extract Program-Footnote-1767889 +Node: Simple Sed768017 +Node: Igawk Program771079 +Ref: Igawk Program-Footnote-1786236 +Ref: Igawk Program-Footnote-2786437 +Node: Anagram Program786575 +Node: Signature Program789643 +Node: Debugger790743 +Node: Debugging791695 +Node: Debugging Concepts792128 +Node: Debugging Terms793984 +Node: Awk Debugging796581 +Node: Sample Debugging Session797473 +Node: Debugger Invocation797993 +Node: Finding The Bug799322 +Node: List of Debugger Commands805810 +Node: Breakpoint Control807144 +Node: Debugger Execution Control810808 +Node: Viewing And Changing Data814168 +Node: Execution Stack817524 +Node: Debugger Info818991 +Node: Miscellaneous Debugger Commands822972 +Node: Readline Support828417 +Node: Limitations829248 +Node: Language History831500 +Node: V7/SVR3.1833012 +Node: SVR4835333 +Node: POSIX836775 +Node: BTL837783 +Node: POSIX/GNU838517 +Node: Common Extensions843668 +Node: Ranges and Locales844775 +Ref: Ranges and Locales-Footnote-1849379 +Node: Contributors849600 +Node: Installation853861 +Node: Gawk Distribution854755 +Node: Getting855239 +Node: Extracting856065 +Node: Distribution contents857757 +Node: Unix Installation862979 +Node: Quick Installation863596 +Node: Additional Configuration Options865558 +Node: Configuration Philosophy867035 +Node: Non-Unix Installation869377 +Node: PC Installation869835 +Node: PC Binary Installation871134 +Node: PC Compiling872982 +Node: PC Testing875926 +Node: PC Using877102 +Node: Cygwin881287 +Node: MSYS882287 +Node: VMS Installation882801 +Node: VMS Compilation883404 +Ref: VMS Compilation-Footnote-1884411 +Node: VMS Installation Details884469 +Node: VMS Running886104 +Node: VMS Old Gawk887711 +Node: Bugs888185 +Node: Other Versions892037 +Node: Notes897352 +Node: Compatibility Mode898044 +Node: Additions898827 +Node: Accessing The Source899639 +Node: Adding Code901064 +Node: New Ports907031 +Node: Dynamic Extensions911144 +Node: Internals912584 +Node: Plugin License921103 +Node: Loading Extensions921741 +Node: Sample Library923551 +Node: Internal File Description924241 +Node: Internal File Ops927956 +Ref: Internal File Ops-Footnote-1932680 +Node: Using Internal File Ops932820 +Node: Future Extensions935197 +Node: Basic Concepts937701 +Node: Basic High Level938458 +Ref: Basic High Level-Footnote-1942493 +Node: Basic Data Typing942678 +Node: Floating Point Issues947203 +Node: String Conversion Precision948286 +Ref: String Conversion Precision-Footnote-1949986 +Node: Unexpected Results950095 +Node: POSIX Floating Point Problems951921 +Ref: POSIX Floating Point Problems-Footnote-1955626 +Node: Glossary955664 +Node: Copying980640 +Node: GNU Free Documentation License1018197 +Node: Index1043334 End Tag Table |