diff options
-rw-r--r-- | awklib/eg/lib/have_mpfr.awk | 9 | ||||
-rw-r--r-- | doc/ChangeLog | 5 | ||||
-rw-r--r-- | doc/gawk.info | 1198 | ||||
-rw-r--r-- | doc/gawk.texi | 58 | ||||
-rw-r--r-- | doc/gawktexi.in | 58 |
5 files changed, 746 insertions, 582 deletions
diff --git a/awklib/eg/lib/have_mpfr.awk b/awklib/eg/lib/have_mpfr.awk new file mode 100644 index 00000000..90bd523b --- /dev/null +++ b/awklib/eg/lib/have_mpfr.awk @@ -0,0 +1,9 @@ +# adequate_math_precision --- return true if we have enough bits +# +# Andrew Schorr, aschorr@telemetry-investments.com, Public Domain +# May 2017 + +function adequate_math_precision(n) +{ + return (1 != (1+(1/(2^(n-1))))) +} diff --git a/doc/ChangeLog b/doc/ChangeLog index 764d093a..e610a6e3 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,8 @@ +2017-05-29 Arnold D. Robbins <arnold@skeeve.com> + + * gawktexi.in (Checking for MPFR): New node on checking if + gawk was invoked with -M. + 2017-05-22 Arnold D. Robbins <arnold@skeeve.com> * gawktexi.in: Document FIELDWIDTHS much better, including how diff --git a/doc/gawk.info b/doc/gawk.info index 14d34a98..2ed1c733 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -536,6 +536,7 @@ in (a) below. A copy of the license is included in the section entitled * Setting the rounding mode:: How to set the rounding mode. * Arbitrary Precision Integers:: Arbitrary Precision Integer Arithmetic with 'gawk'. +* Checking for MPFR:: How to check if MPFR is available. * POSIX Floating Point Problems:: Standards Versus Existing Practice. * Floating point summary:: Summary of floating point discussion. * Extension Intro:: What is an extension. @@ -22486,6 +22487,7 @@ are not quite in agreement. * FP Math Caution:: Things to know. * Arbitrary Precision Integers:: Arbitrary Precision Integer Arithmetic with 'gawk'. +* Checking for MPFR:: How to check if MPFR is available. * POSIX Floating Point Problems:: Standards Versus Existing Practice. * Floating point summary:: Summary of floating point discussion. @@ -23125,7 +23127,7 @@ 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 Integers, Next: POSIX Floating Point Problems, Prev: FP Math Caution, Up: Arbitrary Precision Arithmetic +File: gawk.info, Node: Arbitrary Precision Integers, Next: Checking for MPFR, Prev: FP Math Caution, Up: Arbitrary Precision Arithmetic 15.5 Arbitrary-Precision Integer Arithmetic with 'gawk' ======================================================= @@ -23255,9 +23257,46 @@ Wolfram Web Resource (<http://mathworld.wolfram.com/SylvestersSequence.html>). -File: gawk.info, Node: POSIX Floating Point Problems, Next: Floating point summary, Prev: Arbitrary Precision Integers, Up: Arbitrary Precision Arithmetic +File: gawk.info, Node: Checking for MPFR, Next: POSIX Floating Point Problems, Prev: Arbitrary Precision Integers, Up: Arbitrary Precision Arithmetic -15.6 Standards Versus Existing Practice +15.6 How To Check If MPFR Is Available +====================================== + +Occasionally, you might like to be able to check if 'gawk' was invoked +with the '-M' option, enabling aribtrary-precision arithmetic. You can +do so with the following function, contributed by Andrew Schorr: + + # adequate_math_precision --- return true if we have enough bits + + function adequate_math_precision(n) + { + return (1 != (1+(1/(2^(n-1))))) + } + + Here is code that invokes the function in order to check if +arbitrary-precision arithmetic is available: + + BEGIN { + # How many bits of mantissa precision are required + # for this program to function properly? + fpbits = 123 + + # We hope that we were invoked with MPFR enabled. If so, the + # following statement should configure calculations to our desired + # precision. + PREC = fpbits + + if (! adequate_math_precision(fpbits)) { + print("Error: insufficient computation precision available.\n" \ + "Try again with the -M argument?") > "/dev/stderr" + exit 1 + } + } + + +File: gawk.info, Node: POSIX Floating Point Problems, Next: Floating point summary, Prev: Checking for MPFR, Up: Arbitrary Precision Arithmetic + +15.7 Standards Versus Existing Practice ======================================= Historically, 'awk' has converted any nonnumeric-looking string to the @@ -23344,7 +23383,7 @@ and infinity values. The solution implemented in 'gawk' is as follows: File: gawk.info, Node: Floating point summary, Prev: POSIX Floating Point Problems, Up: Arbitrary Precision Arithmetic -15.7 Summary +15.8 Summary ============ * Most computer arithmetic is done using either integers or @@ -33282,6 +33321,7 @@ Index * Chassell, Robert J.: Acknowledgments. (line 33) * chdir() extension function: Extension Sample File Functions. (line 12) +* checking for MPFR: Checking for MPFR. (line 6) * chem utility: Glossary. (line 206) * chr() extension function: Extension Sample Ord. (line 15) @@ -34610,6 +34650,7 @@ Index * modifiers, in format specifiers: Format Modifiers. (line 6) * monetary information, localization: Explaining gettext. (line 104) * Moore, Duncan: Getline Notes. (line 40) +* MPFR, checking availability of: Checking for MPFR. (line 6) * msgfmt utility: I18N Example. (line 66) * multiple precision: Arbitrary Precision Arithmetic. (line 6) @@ -35680,579 +35721,580 @@ Index Tag Table: Node: Top1200 -Node: Foreword343204 -Node: Foreword447646 -Node: Preface49178 -Ref: Preface-Footnote-152037 -Ref: Preface-Footnote-252144 -Ref: Preface-Footnote-352378 -Node: History52520 -Node: Names54872 -Ref: Names-Footnote-155966 -Node: This Manual56113 -Ref: This Manual-Footnote-162598 -Node: Conventions62698 -Node: Manual History65052 -Ref: Manual History-Footnote-168047 -Ref: Manual History-Footnote-268088 -Node: How To Contribute68162 -Node: Acknowledgments68813 -Node: Getting Started73699 -Node: Running gawk76138 -Node: One-shot77328 -Node: Read Terminal78591 -Node: Long80584 -Node: Executable Scripts82097 -Ref: Executable Scripts-Footnote-184892 -Node: Comments84995 -Node: Quoting87479 -Node: DOS Quoting92996 -Node: Sample Data Files95051 -Node: Very Simple97646 -Node: Two Rules102548 -Node: More Complex104433 -Node: Statements/Lines107299 -Ref: Statements/Lines-Footnote-1111758 -Node: Other Features112023 -Node: When112959 -Ref: When-Footnote-1114713 -Node: Intro Summary114778 -Node: Invoking Gawk115662 -Node: Command Line117176 -Node: Options117974 -Ref: Options-Footnote-1134593 -Ref: Options-Footnote-2134823 -Node: Other Arguments134848 -Node: Naming Standard Input137795 -Node: Environment Variables138888 -Node: AWKPATH Variable139446 -Ref: AWKPATH Variable-Footnote-1142857 -Ref: AWKPATH Variable-Footnote-2142891 -Node: AWKLIBPATH Variable143152 -Node: Other Environment Variables144409 -Node: Exit Status148230 -Node: Include Files148907 -Node: Loading Shared Libraries152502 -Node: Obsolete153930 -Node: Undocumented154622 -Node: Invoking Summary154919 -Node: Regexp156579 -Node: Regexp Usage158033 -Node: Escape Sequences160070 -Node: Regexp Operators166302 -Ref: Regexp Operators-Footnote-1173718 -Ref: Regexp Operators-Footnote-2173865 -Node: Bracket Expressions173963 -Ref: table-char-classes176439 -Node: Leftmost Longest179576 -Node: Computed Regexps180879 -Node: GNU Regexp Operators184306 -Node: Case-sensitivity187985 -Ref: Case-sensitivity-Footnote-1190872 -Ref: Case-sensitivity-Footnote-2191107 -Node: Regexp Summary191215 -Node: Reading Files192681 -Node: Records194950 -Node: awk split records195683 -Node: gawk split records200614 -Ref: gawk split records-Footnote-1205154 -Node: Fields205191 -Node: Nonconstant Fields207932 -Ref: Nonconstant Fields-Footnote-1210168 -Node: Changing Fields210372 -Node: Field Separators216300 -Node: Default Field Splitting218998 -Node: Regexp Field Splitting220116 -Node: Single Character Fields223469 -Node: Command Line Field Separator224529 -Node: Full Line Fields227747 -Ref: Full Line Fields-Footnote-1229269 -Ref: Full Line Fields-Footnote-2229315 -Node: Field Splitting Summary229416 -Node: Constant Size231490 -Node: Fixed width data232222 -Node: Skipping intervening235689 -Node: Allowing trailing data236487 -Node: Fields with fixed data237524 -Node: Splitting By Content239042 -Ref: Splitting By Content-Footnote-1242692 -Node: Testing field creation242855 -Node: Multiple Line244476 -Ref: Multiple Line-Footnote-1250360 -Node: Getline250539 -Node: Plain Getline253008 -Node: Getline/Variable255649 -Node: Getline/File256800 -Node: Getline/Variable/File258188 -Ref: Getline/Variable/File-Footnote-1259793 -Node: Getline/Pipe259881 -Node: Getline/Variable/Pipe262588 -Node: Getline/Coprocess263723 -Node: Getline/Variable/Coprocess264990 -Node: Getline Notes265732 -Node: Getline Summary268529 -Ref: table-getline-variants268953 -Node: Read Timeout269701 -Ref: Read Timeout-Footnote-1273607 -Node: Retrying Input273665 -Node: Command-line directories274864 -Node: Input Summary275770 -Node: Input Exercises278942 -Node: Printing279670 -Node: Print281504 -Node: Print Examples282961 -Node: Output Separators285741 -Node: OFMT287758 -Node: Printf289114 -Node: Basic Printf289899 -Node: Control Letters291473 -Node: Format Modifiers295461 -Node: Printf Examples301476 -Node: Redirection303962 -Node: Special FD310803 -Ref: Special FD-Footnote-1313971 -Node: Special Files314045 -Node: Other Inherited Files314662 -Node: Special Network315663 -Node: Special Caveats316523 -Node: Close Files And Pipes317472 -Ref: table-close-pipe-return-values324379 -Ref: Close Files And Pipes-Footnote-1325162 -Ref: Close Files And Pipes-Footnote-2325310 -Node: Nonfatal325462 -Node: Output Summary327787 -Node: Output Exercises329009 -Node: Expressions329688 -Node: Values330876 -Node: Constants331554 -Node: Scalar Constants332245 -Ref: Scalar Constants-Footnote-1333109 -Node: Nondecimal-numbers333359 -Node: Regexp Constants336360 -Node: Using Constant Regexps336886 -Node: Standard Regexp Constants337508 -Node: Strong Regexp Constants340696 -Node: Variables343654 -Node: Using Variables344311 -Node: Assignment Options346221 -Node: Conversion348094 -Node: Strings And Numbers348618 -Ref: Strings And Numbers-Footnote-1351681 -Node: Locale influences conversions351790 -Ref: table-locale-affects354548 -Node: All Operators355166 -Node: Arithmetic Ops355795 -Node: Concatenation358301 -Ref: Concatenation-Footnote-1361148 -Node: Assignment Ops361255 -Ref: table-assign-ops366246 -Node: Increment Ops367559 -Node: Truth Values and Conditions371019 -Node: Truth Values372093 -Node: Typing and Comparison373141 -Node: Variable Typing373961 -Ref: Variable Typing-Footnote-1380424 -Ref: Variable Typing-Footnote-2380496 -Node: Comparison Operators380573 -Ref: table-relational-ops380992 -Node: POSIX String Comparison384487 -Ref: POSIX String Comparison-Footnote-1386182 -Ref: POSIX String Comparison-Footnote-2386321 -Node: Boolean Ops386405 -Ref: Boolean Ops-Footnote-1390887 -Node: Conditional Exp390979 -Node: Function Calls392715 -Node: Precedence396592 -Node: Locales400251 -Node: Expressions Summary401883 -Node: Patterns and Actions404456 -Node: Pattern Overview405576 -Node: Regexp Patterns407253 -Node: Expression Patterns407795 -Node: Ranges411576 -Node: BEGIN/END414684 -Node: Using BEGIN/END415445 -Ref: Using BEGIN/END-Footnote-1418181 -Node: I/O And BEGIN/END418287 -Node: BEGINFILE/ENDFILE420601 -Node: Empty423508 -Node: Using Shell Variables423825 -Node: Action Overview426099 -Node: Statements428424 -Node: If Statement430272 -Node: While Statement431767 -Node: Do Statement433795 -Node: For Statement434943 -Node: Switch Statement438101 -Node: Break Statement440487 -Node: Continue Statement442579 -Node: Next Statement444406 -Node: Nextfile Statement446789 -Node: Exit Statement449441 -Node: Built-in Variables451844 -Node: User-modified452977 -Node: Auto-set460744 -Ref: Auto-set-Footnote-1475472 -Ref: Auto-set-Footnote-2475678 -Node: ARGC and ARGV475734 -Node: Pattern Action Summary479947 -Node: Arrays482377 -Node: Array Basics483706 -Node: Array Intro484550 -Ref: figure-array-elements486525 -Ref: Array Intro-Footnote-1489229 -Node: Reference to Elements489357 -Node: Assigning Elements491821 -Node: Array Example492312 -Node: Scanning an Array494071 -Node: Controlling Scanning497093 -Ref: Controlling Scanning-Footnote-1502492 -Node: Numeric Array Subscripts502808 -Node: Uninitialized Subscripts504992 -Node: Delete506611 -Ref: Delete-Footnote-1509363 -Node: Multidimensional509420 -Node: Multiscanning512515 -Node: Arrays of Arrays514106 -Node: Arrays Summary518873 -Node: Functions520966 -Node: Built-in522004 -Node: Calling Built-in523085 -Node: Numeric Functions525081 -Ref: Numeric Functions-Footnote-1530026 -Ref: Numeric Functions-Footnote-2530383 -Ref: Numeric Functions-Footnote-3530431 -Node: String Functions530703 -Ref: String Functions-Footnote-1554361 -Ref: String Functions-Footnote-2554489 -Ref: String Functions-Footnote-3554737 -Node: Gory Details554824 -Ref: table-sub-escapes556615 -Ref: table-sub-proposed558134 -Ref: table-posix-sub559497 -Ref: table-gensub-escapes561038 -Ref: Gory Details-Footnote-1561861 -Node: I/O Functions562015 -Ref: table-system-return-values568597 -Ref: I/O Functions-Footnote-1570577 -Ref: I/O Functions-Footnote-2570725 -Node: Time Functions570845 -Ref: Time Functions-Footnote-1581512 -Ref: Time Functions-Footnote-2581580 -Ref: Time Functions-Footnote-3581738 -Ref: Time Functions-Footnote-4581849 -Ref: Time Functions-Footnote-5581961 -Ref: Time Functions-Footnote-6582188 -Node: Bitwise Functions582454 -Ref: table-bitwise-ops583048 -Ref: Bitwise Functions-Footnote-1589081 -Ref: Bitwise Functions-Footnote-2589254 -Node: Type Functions589445 -Node: I18N Functions592120 -Node: User-defined593771 -Node: Definition Syntax594576 -Ref: Definition Syntax-Footnote-1600263 -Node: Function Example600334 -Ref: Function Example-Footnote-1603256 -Node: Function Caveats603278 -Node: Calling A Function603796 -Node: Variable Scope604754 -Node: Pass By Value/Reference607748 -Node: Return Statement611247 -Node: Dynamic Typing614226 -Node: Indirect Calls615156 -Ref: Indirect Calls-Footnote-1625407 -Node: Functions Summary625535 -Node: Library Functions628240 -Ref: Library Functions-Footnote-1631847 -Ref: Library Functions-Footnote-2631990 -Node: Library Names632161 -Ref: Library Names-Footnote-1635621 -Ref: Library Names-Footnote-2635844 -Node: General Functions635930 -Node: Strtonum Function637033 -Node: Assert Function640055 -Node: Round Function643381 -Node: Cliff Random Function644922 -Node: Ordinal Functions645938 -Ref: Ordinal Functions-Footnote-1649001 -Ref: Ordinal Functions-Footnote-2649253 -Node: Join Function649463 -Ref: Join Function-Footnote-1651233 -Node: Getlocaltime Function651433 -Node: Readfile Function655175 -Node: Shell Quoting657147 -Node: Data File Management658548 -Node: Filetrans Function659180 -Node: Rewind Function663276 -Node: File Checking665182 -Ref: File Checking-Footnote-1666516 -Node: Empty Files666717 -Node: Ignoring Assigns668696 -Node: Getopt Function670246 -Ref: Getopt Function-Footnote-1681715 -Node: Passwd Functions681915 -Ref: Passwd Functions-Footnote-1690754 -Node: Group Functions690842 -Ref: Group Functions-Footnote-1698740 -Node: Walking Arrays698947 -Node: Library Functions Summary701955 -Node: Library Exercises703361 -Node: Sample Programs703826 -Node: Running Examples704596 -Node: Clones705324 -Node: Cut Program706548 -Node: Egrep Program716477 -Ref: Egrep Program-Footnote-1723989 -Node: Id Program724099 -Node: Split Program727779 -Ref: Split Program-Footnote-1731238 -Node: Tee Program731367 -Node: Uniq Program734157 -Node: Wc Program741583 -Ref: Wc Program-Footnote-1745838 -Node: Miscellaneous Programs745932 -Node: Dupword Program747145 -Node: Alarm Program749175 -Node: Translate Program754030 -Ref: Translate Program-Footnote-1758595 -Node: Labels Program758865 -Ref: Labels Program-Footnote-1762216 -Node: Word Sorting762300 -Node: History Sorting766372 -Node: Extract Program768207 -Node: Simple Sed775736 -Node: Igawk Program778810 -Ref: Igawk Program-Footnote-1793141 -Ref: Igawk Program-Footnote-2793343 -Ref: Igawk Program-Footnote-3793465 -Node: Anagram Program793580 -Node: Signature Program796642 -Node: Programs Summary797889 -Node: Programs Exercises799103 -Ref: Programs Exercises-Footnote-1803232 -Node: Advanced Features803323 -Node: Nondecimal Data805313 -Node: Array Sorting806904 -Node: Controlling Array Traversal807604 -Ref: Controlling Array Traversal-Footnote-1815971 -Node: Array Sorting Functions816089 -Ref: Array Sorting Functions-Footnote-1821180 -Node: Two-way I/O821376 -Ref: Two-way I/O-Footnote-1827927 -Ref: Two-way I/O-Footnote-2828114 -Node: TCP/IP Networking828196 -Node: Profiling831314 -Ref: Profiling-Footnote-1839986 -Node: Advanced Features Summary840309 -Node: Internationalization842153 -Node: I18N and L10N843633 -Node: Explaining gettext844320 -Ref: Explaining gettext-Footnote-1850212 -Ref: Explaining gettext-Footnote-2850397 -Node: Programmer i18n850562 -Ref: Programmer i18n-Footnote-1855511 -Node: Translator i18n855560 -Node: String Extraction856354 -Ref: String Extraction-Footnote-1857486 -Node: Printf Ordering857572 -Ref: Printf Ordering-Footnote-1860358 -Node: I18N Portability860422 -Ref: I18N Portability-Footnote-1862878 -Node: I18N Example862941 -Ref: I18N Example-Footnote-1865747 -Node: Gawk I18N865820 -Node: I18N Summary866465 -Node: Debugger867806 -Node: Debugging868828 -Node: Debugging Concepts869269 -Node: Debugging Terms871078 -Node: Awk Debugging873653 -Node: Sample Debugging Session874559 -Node: Debugger Invocation875093 -Node: Finding The Bug876479 -Node: List of Debugger Commands882957 -Node: Breakpoint Control884290 -Node: Debugger Execution Control887984 -Node: Viewing And Changing Data891346 -Node: Execution Stack894720 -Node: Debugger Info896357 -Node: Miscellaneous Debugger Commands900428 -Node: Readline Support905516 -Node: Limitations906412 -Node: Debugging Summary908521 -Node: Arbitrary Precision Arithmetic909800 -Node: Computer Arithmetic911216 -Ref: table-numeric-ranges914807 -Ref: Computer Arithmetic-Footnote-1915529 -Node: Math Definitions915586 -Ref: table-ieee-formats918900 -Ref: Math Definitions-Footnote-1919503 -Node: MPFR features919608 -Node: FP Math Caution921325 -Ref: FP Math Caution-Footnote-1922397 -Node: Inexactness of computations922766 -Node: Inexact representation923726 -Node: Comparing FP Values925086 -Node: Errors accumulate926168 -Node: Getting Accuracy927601 -Node: Try To Round930311 -Node: Setting precision931210 -Ref: table-predefined-precision-strings931907 -Node: Setting the rounding mode933737 -Ref: table-gawk-rounding-modes934111 -Ref: Setting the rounding mode-Footnote-1937519 -Node: Arbitrary Precision Integers937698 -Ref: Arbitrary Precision Integers-Footnote-1942615 -Node: POSIX Floating Point Problems942764 -Ref: POSIX Floating Point Problems-Footnote-1946646 -Node: Floating point summary946684 -Node: Dynamic Extensions948874 -Node: Extension Intro950427 -Node: Plugin License951693 -Node: Extension Mechanism Outline952490 -Ref: figure-load-extension952929 -Ref: figure-register-new-function954494 -Ref: figure-call-new-function955586 -Node: Extension API Description957648 -Node: Extension API Functions Introduction959290 -Node: General Data Types964624 -Ref: General Data Types-Footnote-1971829 -Node: Memory Allocation Functions972128 -Ref: Memory Allocation Functions-Footnote-1974973 -Node: Constructor Functions975072 -Node: Registration Functions978071 -Node: Extension Functions978756 -Node: Exit Callback Functions983969 -Node: Extension Version String985219 -Node: Input Parsers985882 -Node: Output Wrappers998589 -Node: Two-way processors1003101 -Node: Printing Messages1005366 -Ref: Printing Messages-Footnote-11006537 -Node: Updating ERRNO1006690 -Node: Requesting Values1007429 -Ref: table-value-types-returned1008166 -Node: Accessing Parameters1009102 -Node: Symbol Table Access1010337 -Node: Symbol table by name1010849 -Node: Symbol table by cookie1012638 -Ref: Symbol table by cookie-Footnote-11016823 -Node: Cached values1016887 -Ref: Cached values-Footnote-11020423 -Node: Array Manipulation1020514 -Ref: Array Manipulation-Footnote-11021605 -Node: Array Data Types1021642 -Ref: Array Data Types-Footnote-11024300 -Node: Array Functions1024392 -Node: Flattening Arrays1028791 -Node: Creating Arrays1035732 -Node: Redirection API1040501 -Node: Extension API Variables1043343 -Node: Extension Versioning1043976 -Ref: gawk-api-version1044413 -Node: Extension API Informational Variables1046141 -Node: Extension API Boilerplate1047205 -Node: Changes from API V11051067 -Node: Finding Extensions1051727 -Node: Extension Example1052286 -Node: Internal File Description1053084 -Node: Internal File Ops1057164 -Ref: Internal File Ops-Footnote-11068564 -Node: Using Internal File Ops1068704 -Ref: Using Internal File Ops-Footnote-11071087 -Node: Extension Samples1071361 -Node: Extension Sample File Functions1072890 -Node: Extension Sample Fnmatch1080539 -Node: Extension Sample Fork1082026 -Node: Extension Sample Inplace1083244 -Node: Extension Sample Ord1086454 -Node: Extension Sample Readdir1087290 -Ref: table-readdir-file-types1088179 -Node: Extension Sample Revout1088984 -Node: Extension Sample Rev2way1089573 -Node: Extension Sample Read write array1090313 -Node: Extension Sample Readfile1092255 -Node: Extension Sample Time1093350 -Node: Extension Sample API Tests1094698 -Node: gawkextlib1095190 -Node: Extension summary1097637 -Node: Extension Exercises1101339 -Node: Language History1102837 -Node: V7/SVR3.11104493 -Node: SVR41106645 -Node: POSIX1108079 -Node: BTL1109458 -Node: POSIX/GNU1110187 -Node: Feature History1116079 -Node: Common Extensions1130449 -Node: Ranges and Locales1131732 -Ref: Ranges and Locales-Footnote-11136348 -Ref: Ranges and Locales-Footnote-21136375 -Ref: Ranges and Locales-Footnote-31136610 -Node: Contributors1136831 -Node: History summary1142391 -Node: Installation1143771 -Node: Gawk Distribution1144715 -Node: Getting1145199 -Node: Extracting1146160 -Node: Distribution contents1147798 -Node: Unix Installation1154140 -Node: Quick Installation1154822 -Node: Shell Startup Files1157236 -Node: Additional Configuration Options1158325 -Node: Configuration Philosophy1160314 -Node: Non-Unix Installation1162683 -Node: PC Installation1163143 -Node: PC Binary Installation1163981 -Node: PC Compiling1164416 -Node: PC Using1165533 -Node: Cygwin1168578 -Node: MSYS1169348 -Node: VMS Installation1169849 -Node: VMS Compilation1170640 -Ref: VMS Compilation-Footnote-11171869 -Node: VMS Dynamic Extensions1171927 -Node: VMS Installation Details1173612 -Node: VMS Running1175865 -Node: VMS GNV1180144 -Node: VMS Old Gawk1180879 -Node: Bugs1181350 -Node: Bug address1182013 -Node: Usenet1184410 -Node: Maintainers1185187 -Node: Other Versions1186563 -Node: Installation summary1193147 -Node: Notes1194182 -Node: Compatibility Mode1195047 -Node: Additions1195829 -Node: Accessing The Source1196754 -Node: Adding Code1198189 -Node: New Ports1204407 -Node: Derived Files1208895 -Ref: Derived Files-Footnote-11214380 -Ref: Derived Files-Footnote-21214415 -Ref: Derived Files-Footnote-31215013 -Node: Future Extensions1215127 -Node: Implementation Limitations1215785 -Node: Extension Design1216968 -Node: Old Extension Problems1218122 -Ref: Old Extension Problems-Footnote-11219640 -Node: Extension New Mechanism Goals1219697 -Ref: Extension New Mechanism Goals-Footnote-11223061 -Node: Extension Other Design Decisions1223250 -Node: Extension Future Growth1225363 -Node: Old Extension Mechanism1226199 -Node: Notes summary1227962 -Node: Basic Concepts1229144 -Node: Basic High Level1229825 -Ref: figure-general-flow1230107 -Ref: figure-process-flow1230792 -Ref: Basic High Level-Footnote-11234093 -Node: Basic Data Typing1234278 -Node: Glossary1237606 -Node: Copying1269553 -Node: GNU Free Documentation License1307092 -Node: Index1332210 +Node: Foreword343279 +Node: Foreword447721 +Node: Preface49253 +Ref: Preface-Footnote-152112 +Ref: Preface-Footnote-252219 +Ref: Preface-Footnote-352453 +Node: History52595 +Node: Names54947 +Ref: Names-Footnote-156041 +Node: This Manual56188 +Ref: This Manual-Footnote-162673 +Node: Conventions62773 +Node: Manual History65127 +Ref: Manual History-Footnote-168122 +Ref: Manual History-Footnote-268163 +Node: How To Contribute68237 +Node: Acknowledgments68888 +Node: Getting Started73774 +Node: Running gawk76213 +Node: One-shot77403 +Node: Read Terminal78666 +Node: Long80659 +Node: Executable Scripts82172 +Ref: Executable Scripts-Footnote-184967 +Node: Comments85070 +Node: Quoting87554 +Node: DOS Quoting93071 +Node: Sample Data Files95126 +Node: Very Simple97721 +Node: Two Rules102623 +Node: More Complex104508 +Node: Statements/Lines107374 +Ref: Statements/Lines-Footnote-1111833 +Node: Other Features112098 +Node: When113034 +Ref: When-Footnote-1114788 +Node: Intro Summary114853 +Node: Invoking Gawk115737 +Node: Command Line117251 +Node: Options118049 +Ref: Options-Footnote-1134668 +Ref: Options-Footnote-2134898 +Node: Other Arguments134923 +Node: Naming Standard Input137870 +Node: Environment Variables138963 +Node: AWKPATH Variable139521 +Ref: AWKPATH Variable-Footnote-1142932 +Ref: AWKPATH Variable-Footnote-2142966 +Node: AWKLIBPATH Variable143227 +Node: Other Environment Variables144484 +Node: Exit Status148305 +Node: Include Files148982 +Node: Loading Shared Libraries152577 +Node: Obsolete154005 +Node: Undocumented154697 +Node: Invoking Summary154994 +Node: Regexp156654 +Node: Regexp Usage158108 +Node: Escape Sequences160145 +Node: Regexp Operators166377 +Ref: Regexp Operators-Footnote-1173793 +Ref: Regexp Operators-Footnote-2173940 +Node: Bracket Expressions174038 +Ref: table-char-classes176514 +Node: Leftmost Longest179651 +Node: Computed Regexps180954 +Node: GNU Regexp Operators184381 +Node: Case-sensitivity188060 +Ref: Case-sensitivity-Footnote-1190947 +Ref: Case-sensitivity-Footnote-2191182 +Node: Regexp Summary191290 +Node: Reading Files192756 +Node: Records195025 +Node: awk split records195758 +Node: gawk split records200689 +Ref: gawk split records-Footnote-1205229 +Node: Fields205266 +Node: Nonconstant Fields208007 +Ref: Nonconstant Fields-Footnote-1210243 +Node: Changing Fields210447 +Node: Field Separators216375 +Node: Default Field Splitting219073 +Node: Regexp Field Splitting220191 +Node: Single Character Fields223544 +Node: Command Line Field Separator224604 +Node: Full Line Fields227822 +Ref: Full Line Fields-Footnote-1229344 +Ref: Full Line Fields-Footnote-2229390 +Node: Field Splitting Summary229491 +Node: Constant Size231565 +Node: Fixed width data232297 +Node: Skipping intervening235764 +Node: Allowing trailing data236562 +Node: Fields with fixed data237599 +Node: Splitting By Content239117 +Ref: Splitting By Content-Footnote-1242767 +Node: Testing field creation242930 +Node: Multiple Line244551 +Ref: Multiple Line-Footnote-1250435 +Node: Getline250614 +Node: Plain Getline253083 +Node: Getline/Variable255724 +Node: Getline/File256875 +Node: Getline/Variable/File258263 +Ref: Getline/Variable/File-Footnote-1259868 +Node: Getline/Pipe259956 +Node: Getline/Variable/Pipe262663 +Node: Getline/Coprocess263798 +Node: Getline/Variable/Coprocess265065 +Node: Getline Notes265807 +Node: Getline Summary268604 +Ref: table-getline-variants269028 +Node: Read Timeout269776 +Ref: Read Timeout-Footnote-1273682 +Node: Retrying Input273740 +Node: Command-line directories274939 +Node: Input Summary275845 +Node: Input Exercises279017 +Node: Printing279745 +Node: Print281579 +Node: Print Examples283036 +Node: Output Separators285816 +Node: OFMT287833 +Node: Printf289189 +Node: Basic Printf289974 +Node: Control Letters291548 +Node: Format Modifiers295536 +Node: Printf Examples301551 +Node: Redirection304037 +Node: Special FD310878 +Ref: Special FD-Footnote-1314046 +Node: Special Files314120 +Node: Other Inherited Files314737 +Node: Special Network315738 +Node: Special Caveats316598 +Node: Close Files And Pipes317547 +Ref: table-close-pipe-return-values324454 +Ref: Close Files And Pipes-Footnote-1325237 +Ref: Close Files And Pipes-Footnote-2325385 +Node: Nonfatal325537 +Node: Output Summary327862 +Node: Output Exercises329084 +Node: Expressions329763 +Node: Values330951 +Node: Constants331629 +Node: Scalar Constants332320 +Ref: Scalar Constants-Footnote-1333184 +Node: Nondecimal-numbers333434 +Node: Regexp Constants336435 +Node: Using Constant Regexps336961 +Node: Standard Regexp Constants337583 +Node: Strong Regexp Constants340771 +Node: Variables343729 +Node: Using Variables344386 +Node: Assignment Options346296 +Node: Conversion348169 +Node: Strings And Numbers348693 +Ref: Strings And Numbers-Footnote-1351756 +Node: Locale influences conversions351865 +Ref: table-locale-affects354623 +Node: All Operators355241 +Node: Arithmetic Ops355870 +Node: Concatenation358376 +Ref: Concatenation-Footnote-1361223 +Node: Assignment Ops361330 +Ref: table-assign-ops366321 +Node: Increment Ops367634 +Node: Truth Values and Conditions371094 +Node: Truth Values372168 +Node: Typing and Comparison373216 +Node: Variable Typing374036 +Ref: Variable Typing-Footnote-1380499 +Ref: Variable Typing-Footnote-2380571 +Node: Comparison Operators380648 +Ref: table-relational-ops381067 +Node: POSIX String Comparison384562 +Ref: POSIX String Comparison-Footnote-1386257 +Ref: POSIX String Comparison-Footnote-2386396 +Node: Boolean Ops386480 +Ref: Boolean Ops-Footnote-1390962 +Node: Conditional Exp391054 +Node: Function Calls392790 +Node: Precedence396667 +Node: Locales400326 +Node: Expressions Summary401958 +Node: Patterns and Actions404531 +Node: Pattern Overview405651 +Node: Regexp Patterns407328 +Node: Expression Patterns407870 +Node: Ranges411651 +Node: BEGIN/END414759 +Node: Using BEGIN/END415520 +Ref: Using BEGIN/END-Footnote-1418256 +Node: I/O And BEGIN/END418362 +Node: BEGINFILE/ENDFILE420676 +Node: Empty423583 +Node: Using Shell Variables423900 +Node: Action Overview426174 +Node: Statements428499 +Node: If Statement430347 +Node: While Statement431842 +Node: Do Statement433870 +Node: For Statement435018 +Node: Switch Statement438176 +Node: Break Statement440562 +Node: Continue Statement442654 +Node: Next Statement444481 +Node: Nextfile Statement446864 +Node: Exit Statement449516 +Node: Built-in Variables451919 +Node: User-modified453052 +Node: Auto-set460819 +Ref: Auto-set-Footnote-1475547 +Ref: Auto-set-Footnote-2475753 +Node: ARGC and ARGV475809 +Node: Pattern Action Summary480022 +Node: Arrays482452 +Node: Array Basics483781 +Node: Array Intro484625 +Ref: figure-array-elements486600 +Ref: Array Intro-Footnote-1489304 +Node: Reference to Elements489432 +Node: Assigning Elements491896 +Node: Array Example492387 +Node: Scanning an Array494146 +Node: Controlling Scanning497168 +Ref: Controlling Scanning-Footnote-1502567 +Node: Numeric Array Subscripts502883 +Node: Uninitialized Subscripts505067 +Node: Delete506686 +Ref: Delete-Footnote-1509438 +Node: Multidimensional509495 +Node: Multiscanning512590 +Node: Arrays of Arrays514181 +Node: Arrays Summary518948 +Node: Functions521041 +Node: Built-in522079 +Node: Calling Built-in523160 +Node: Numeric Functions525156 +Ref: Numeric Functions-Footnote-1530101 +Ref: Numeric Functions-Footnote-2530458 +Ref: Numeric Functions-Footnote-3530506 +Node: String Functions530778 +Ref: String Functions-Footnote-1554436 +Ref: String Functions-Footnote-2554564 +Ref: String Functions-Footnote-3554812 +Node: Gory Details554899 +Ref: table-sub-escapes556690 +Ref: table-sub-proposed558209 +Ref: table-posix-sub559572 +Ref: table-gensub-escapes561113 +Ref: Gory Details-Footnote-1561936 +Node: I/O Functions562090 +Ref: table-system-return-values568672 +Ref: I/O Functions-Footnote-1570652 +Ref: I/O Functions-Footnote-2570800 +Node: Time Functions570920 +Ref: Time Functions-Footnote-1581587 +Ref: Time Functions-Footnote-2581655 +Ref: Time Functions-Footnote-3581813 +Ref: Time Functions-Footnote-4581924 +Ref: Time Functions-Footnote-5582036 +Ref: Time Functions-Footnote-6582263 +Node: Bitwise Functions582529 +Ref: table-bitwise-ops583123 +Ref: Bitwise Functions-Footnote-1589156 +Ref: Bitwise Functions-Footnote-2589329 +Node: Type Functions589520 +Node: I18N Functions592195 +Node: User-defined593846 +Node: Definition Syntax594651 +Ref: Definition Syntax-Footnote-1600338 +Node: Function Example600409 +Ref: Function Example-Footnote-1603331 +Node: Function Caveats603353 +Node: Calling A Function603871 +Node: Variable Scope604829 +Node: Pass By Value/Reference607823 +Node: Return Statement611322 +Node: Dynamic Typing614301 +Node: Indirect Calls615231 +Ref: Indirect Calls-Footnote-1625482 +Node: Functions Summary625610 +Node: Library Functions628315 +Ref: Library Functions-Footnote-1631922 +Ref: Library Functions-Footnote-2632065 +Node: Library Names632236 +Ref: Library Names-Footnote-1635696 +Ref: Library Names-Footnote-2635919 +Node: General Functions636005 +Node: Strtonum Function637108 +Node: Assert Function640130 +Node: Round Function643456 +Node: Cliff Random Function644997 +Node: Ordinal Functions646013 +Ref: Ordinal Functions-Footnote-1649076 +Ref: Ordinal Functions-Footnote-2649328 +Node: Join Function649538 +Ref: Join Function-Footnote-1651308 +Node: Getlocaltime Function651508 +Node: Readfile Function655250 +Node: Shell Quoting657222 +Node: Data File Management658623 +Node: Filetrans Function659255 +Node: Rewind Function663351 +Node: File Checking665257 +Ref: File Checking-Footnote-1666591 +Node: Empty Files666792 +Node: Ignoring Assigns668771 +Node: Getopt Function670321 +Ref: Getopt Function-Footnote-1681790 +Node: Passwd Functions681990 +Ref: Passwd Functions-Footnote-1690829 +Node: Group Functions690917 +Ref: Group Functions-Footnote-1698815 +Node: Walking Arrays699022 +Node: Library Functions Summary702030 +Node: Library Exercises703436 +Node: Sample Programs703901 +Node: Running Examples704671 +Node: Clones705399 +Node: Cut Program706623 +Node: Egrep Program716552 +Ref: Egrep Program-Footnote-1724064 +Node: Id Program724174 +Node: Split Program727854 +Ref: Split Program-Footnote-1731313 +Node: Tee Program731442 +Node: Uniq Program734232 +Node: Wc Program741658 +Ref: Wc Program-Footnote-1745913 +Node: Miscellaneous Programs746007 +Node: Dupword Program747220 +Node: Alarm Program749250 +Node: Translate Program754105 +Ref: Translate Program-Footnote-1758670 +Node: Labels Program758940 +Ref: Labels Program-Footnote-1762291 +Node: Word Sorting762375 +Node: History Sorting766447 +Node: Extract Program768282 +Node: Simple Sed775811 +Node: Igawk Program778885 +Ref: Igawk Program-Footnote-1793216 +Ref: Igawk Program-Footnote-2793418 +Ref: Igawk Program-Footnote-3793540 +Node: Anagram Program793655 +Node: Signature Program796717 +Node: Programs Summary797964 +Node: Programs Exercises799178 +Ref: Programs Exercises-Footnote-1803307 +Node: Advanced Features803398 +Node: Nondecimal Data805388 +Node: Array Sorting806979 +Node: Controlling Array Traversal807679 +Ref: Controlling Array Traversal-Footnote-1816046 +Node: Array Sorting Functions816164 +Ref: Array Sorting Functions-Footnote-1821255 +Node: Two-way I/O821451 +Ref: Two-way I/O-Footnote-1828002 +Ref: Two-way I/O-Footnote-2828189 +Node: TCP/IP Networking828271 +Node: Profiling831389 +Ref: Profiling-Footnote-1840061 +Node: Advanced Features Summary840384 +Node: Internationalization842228 +Node: I18N and L10N843708 +Node: Explaining gettext844395 +Ref: Explaining gettext-Footnote-1850287 +Ref: Explaining gettext-Footnote-2850472 +Node: Programmer i18n850637 +Ref: Programmer i18n-Footnote-1855586 +Node: Translator i18n855635 +Node: String Extraction856429 +Ref: String Extraction-Footnote-1857561 +Node: Printf Ordering857647 +Ref: Printf Ordering-Footnote-1860433 +Node: I18N Portability860497 +Ref: I18N Portability-Footnote-1862953 +Node: I18N Example863016 +Ref: I18N Example-Footnote-1865822 +Node: Gawk I18N865895 +Node: I18N Summary866540 +Node: Debugger867881 +Node: Debugging868903 +Node: Debugging Concepts869344 +Node: Debugging Terms871153 +Node: Awk Debugging873728 +Node: Sample Debugging Session874634 +Node: Debugger Invocation875168 +Node: Finding The Bug876554 +Node: List of Debugger Commands883032 +Node: Breakpoint Control884365 +Node: Debugger Execution Control888059 +Node: Viewing And Changing Data891421 +Node: Execution Stack894795 +Node: Debugger Info896432 +Node: Miscellaneous Debugger Commands900503 +Node: Readline Support905591 +Node: Limitations906487 +Node: Debugging Summary908596 +Node: Arbitrary Precision Arithmetic909875 +Node: Computer Arithmetic911360 +Ref: table-numeric-ranges914951 +Ref: Computer Arithmetic-Footnote-1915673 +Node: Math Definitions915730 +Ref: table-ieee-formats919044 +Ref: Math Definitions-Footnote-1919647 +Node: MPFR features919752 +Node: FP Math Caution921469 +Ref: FP Math Caution-Footnote-1922541 +Node: Inexactness of computations922910 +Node: Inexact representation923870 +Node: Comparing FP Values925230 +Node: Errors accumulate926312 +Node: Getting Accuracy927745 +Node: Try To Round930455 +Node: Setting precision931354 +Ref: table-predefined-precision-strings932051 +Node: Setting the rounding mode933881 +Ref: table-gawk-rounding-modes934255 +Ref: Setting the rounding mode-Footnote-1937663 +Node: Arbitrary Precision Integers937842 +Ref: Arbitrary Precision Integers-Footnote-1942747 +Node: Checking for MPFR942896 +Node: POSIX Floating Point Problems944193 +Ref: POSIX Floating Point Problems-Footnote-1948064 +Node: Floating point summary948102 +Node: Dynamic Extensions950292 +Node: Extension Intro951845 +Node: Plugin License953111 +Node: Extension Mechanism Outline953908 +Ref: figure-load-extension954347 +Ref: figure-register-new-function955912 +Ref: figure-call-new-function957004 +Node: Extension API Description959066 +Node: Extension API Functions Introduction960708 +Node: General Data Types966042 +Ref: General Data Types-Footnote-1973247 +Node: Memory Allocation Functions973546 +Ref: Memory Allocation Functions-Footnote-1976391 +Node: Constructor Functions976490 +Node: Registration Functions979489 +Node: Extension Functions980174 +Node: Exit Callback Functions985387 +Node: Extension Version String986637 +Node: Input Parsers987300 +Node: Output Wrappers1000007 +Node: Two-way processors1004519 +Node: Printing Messages1006784 +Ref: Printing Messages-Footnote-11007955 +Node: Updating ERRNO1008108 +Node: Requesting Values1008847 +Ref: table-value-types-returned1009584 +Node: Accessing Parameters1010520 +Node: Symbol Table Access1011755 +Node: Symbol table by name1012267 +Node: Symbol table by cookie1014056 +Ref: Symbol table by cookie-Footnote-11018241 +Node: Cached values1018305 +Ref: Cached values-Footnote-11021841 +Node: Array Manipulation1021932 +Ref: Array Manipulation-Footnote-11023023 +Node: Array Data Types1023060 +Ref: Array Data Types-Footnote-11025718 +Node: Array Functions1025810 +Node: Flattening Arrays1030209 +Node: Creating Arrays1037150 +Node: Redirection API1041919 +Node: Extension API Variables1044761 +Node: Extension Versioning1045394 +Ref: gawk-api-version1045831 +Node: Extension API Informational Variables1047559 +Node: Extension API Boilerplate1048623 +Node: Changes from API V11052485 +Node: Finding Extensions1053145 +Node: Extension Example1053704 +Node: Internal File Description1054502 +Node: Internal File Ops1058582 +Ref: Internal File Ops-Footnote-11069982 +Node: Using Internal File Ops1070122 +Ref: Using Internal File Ops-Footnote-11072505 +Node: Extension Samples1072779 +Node: Extension Sample File Functions1074308 +Node: Extension Sample Fnmatch1081957 +Node: Extension Sample Fork1083444 +Node: Extension Sample Inplace1084662 +Node: Extension Sample Ord1087872 +Node: Extension Sample Readdir1088708 +Ref: table-readdir-file-types1089597 +Node: Extension Sample Revout1090402 +Node: Extension Sample Rev2way1090991 +Node: Extension Sample Read write array1091731 +Node: Extension Sample Readfile1093673 +Node: Extension Sample Time1094768 +Node: Extension Sample API Tests1096116 +Node: gawkextlib1096608 +Node: Extension summary1099055 +Node: Extension Exercises1102757 +Node: Language History1104255 +Node: V7/SVR3.11105911 +Node: SVR41108063 +Node: POSIX1109497 +Node: BTL1110876 +Node: POSIX/GNU1111605 +Node: Feature History1117497 +Node: Common Extensions1131867 +Node: Ranges and Locales1133150 +Ref: Ranges and Locales-Footnote-11137766 +Ref: Ranges and Locales-Footnote-21137793 +Ref: Ranges and Locales-Footnote-31138028 +Node: Contributors1138249 +Node: History summary1143809 +Node: Installation1145189 +Node: Gawk Distribution1146133 +Node: Getting1146617 +Node: Extracting1147578 +Node: Distribution contents1149216 +Node: Unix Installation1155558 +Node: Quick Installation1156240 +Node: Shell Startup Files1158654 +Node: Additional Configuration Options1159743 +Node: Configuration Philosophy1161732 +Node: Non-Unix Installation1164101 +Node: PC Installation1164561 +Node: PC Binary Installation1165399 +Node: PC Compiling1165834 +Node: PC Using1166951 +Node: Cygwin1169996 +Node: MSYS1170766 +Node: VMS Installation1171267 +Node: VMS Compilation1172058 +Ref: VMS Compilation-Footnote-11173287 +Node: VMS Dynamic Extensions1173345 +Node: VMS Installation Details1175030 +Node: VMS Running1177283 +Node: VMS GNV1181562 +Node: VMS Old Gawk1182297 +Node: Bugs1182768 +Node: Bug address1183431 +Node: Usenet1185828 +Node: Maintainers1186605 +Node: Other Versions1187981 +Node: Installation summary1194565 +Node: Notes1195600 +Node: Compatibility Mode1196465 +Node: Additions1197247 +Node: Accessing The Source1198172 +Node: Adding Code1199607 +Node: New Ports1205825 +Node: Derived Files1210313 +Ref: Derived Files-Footnote-11215798 +Ref: Derived Files-Footnote-21215833 +Ref: Derived Files-Footnote-31216431 +Node: Future Extensions1216545 +Node: Implementation Limitations1217203 +Node: Extension Design1218386 +Node: Old Extension Problems1219540 +Ref: Old Extension Problems-Footnote-11221058 +Node: Extension New Mechanism Goals1221115 +Ref: Extension New Mechanism Goals-Footnote-11224479 +Node: Extension Other Design Decisions1224668 +Node: Extension Future Growth1226781 +Node: Old Extension Mechanism1227617 +Node: Notes summary1229380 +Node: Basic Concepts1230562 +Node: Basic High Level1231243 +Ref: figure-general-flow1231525 +Ref: figure-process-flow1232210 +Ref: Basic High Level-Footnote-11235511 +Node: Basic Data Typing1235696 +Node: Glossary1239024 +Node: Copying1270971 +Node: GNU Free Documentation License1308510 +Node: Index1333628 End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index 5b9eeed7..e7d75521 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -64,7 +64,7 @@ @c applies to and all the info about who's publishing this edition @c These apply across the board. -@set UPDATE-MONTH January, 2017 +@set UPDATE-MONTH May, 2017 @set VERSION 4.1 @set PATCHLEVEL 4 @@ -908,6 +908,7 @@ particular records in a file and perform operations upon them. * Setting the rounding mode:: How to set the rounding mode. * Arbitrary Precision Integers:: Arbitrary Precision Integer Arithmetic with @command{gawk}. +* Checking for MPFR:: How to check if MPFR is available. * POSIX Floating Point Problems:: Standards Versus Existing Practice. * Floating point summary:: Summary of floating point discussion. * Extension Intro:: What is an extension. @@ -4988,7 +4989,7 @@ the name by which @command{gawk} was invoked. Here is an example of how this feature may be used: @example -awk ' +gawk ' BEGIN @{ for (i = 0; i < length(PROCINFO["argv"]); i++) print i, PROCINFO["argv"][i] @@ -31224,6 +31225,7 @@ this is the place to be. * FP Math Caution:: Things to know. * Arbitrary Precision Integers:: Arbitrary Precision Integer Arithmetic with @command{gawk}. +* Checking for MPFR:: How to check if MPFR is available. * POSIX Floating Point Problems:: Standards Versus Existing Practice. * Floating point summary:: Summary of floating point discussion. @end menu @@ -32125,6 +32127,58 @@ word sizes. See @uref{http://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/articles.cgi?read=899}. @end quotation +@node Checking for MPFR +@section How To Check If MPFR Is Available + +@cindex MPFR, checking availability of +@cindex checking for MPFR +Occasionally, you might like to be able to check if @command{gawk} +was invoked with the @option{-M} option, enabling aribtrary-precision +arithmetic. You can do so with the following function, contributed +by Andrew Schorr: + +@example +@c file eg/lib/have_mpfr.awk +# adequate_math_precision --- return true if we have enough bits +@c endfile +@ignore +@c file eg/lib/have_mpfr.awk +# +# Andrew Schorr, aschorr@@telemetry-investments.com, Public Domain +# May 2017 +@c endfile +@end ignore +@c file eg/lib/have_mpfr.awk + +function adequate_math_precision(n) +@{ + return (1 != (1+(1/(2^(n-1))))) +@} +@c endfile +@end example + +Here is code that invokes the function in order to check +if arbitrary-precision arithmetic is available: + +@example +BEGIN @{ + # How many bits of mantissa precision are required + # for this program to function properly? + fpbits = 123 + + # We hope that we were invoked with MPFR enabled. If so, the + # following statement should configure calculations to our desired + # precision. + PREC = fpbits + + if (! adequate_math_precision(fpbits)) @{ + print("Error: insufficient computation precision available.\n" \ + "Try again with the -M argument?") > "/dev/stderr" + exit 1 + @} +@} +@end example + @node POSIX Floating Point Problems @section Standards Versus Existing Practice diff --git a/doc/gawktexi.in b/doc/gawktexi.in index 1e1b1340..f95360d2 100644 --- a/doc/gawktexi.in +++ b/doc/gawktexi.in @@ -59,7 +59,7 @@ @c applies to and all the info about who's publishing this edition @c These apply across the board. -@set UPDATE-MONTH January, 2017 +@set UPDATE-MONTH May, 2017 @set VERSION 4.1 @set PATCHLEVEL 4 @@ -903,6 +903,7 @@ particular records in a file and perform operations upon them. * Setting the rounding mode:: How to set the rounding mode. * Arbitrary Precision Integers:: Arbitrary Precision Integer Arithmetic with @command{gawk}. +* Checking for MPFR:: How to check if MPFR is available. * POSIX Floating Point Problems:: Standards Versus Existing Practice. * Floating point summary:: Summary of floating point discussion. * Extension Intro:: What is an extension. @@ -4899,7 +4900,7 @@ the name by which @command{gawk} was invoked. Here is an example of how this feature may be used: @example -awk ' +gawk ' BEGIN @{ for (i = 0; i < length(PROCINFO["argv"]); i++) print i, PROCINFO["argv"][i] @@ -30238,6 +30239,7 @@ this is the place to be. * FP Math Caution:: Things to know. * Arbitrary Precision Integers:: Arbitrary Precision Integer Arithmetic with @command{gawk}. +* Checking for MPFR:: How to check if MPFR is available. * POSIX Floating Point Problems:: Standards Versus Existing Practice. * Floating point summary:: Summary of floating point discussion. @end menu @@ -31139,6 +31141,58 @@ word sizes. See @uref{http://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/articles.cgi?read=899}. @end quotation +@node Checking for MPFR +@section How To Check If MPFR Is Available + +@cindex MPFR, checking availability of +@cindex checking for MPFR +Occasionally, you might like to be able to check if @command{gawk} +was invoked with the @option{-M} option, enabling aribtrary-precision +arithmetic. You can do so with the following function, contributed +by Andrew Schorr: + +@example +@c file eg/lib/have_mpfr.awk +# adequate_math_precision --- return true if we have enough bits +@c endfile +@ignore +@c file eg/lib/have_mpfr.awk +# +# Andrew Schorr, aschorr@@telemetry-investments.com, Public Domain +# May 2017 +@c endfile +@end ignore +@c file eg/lib/have_mpfr.awk + +function adequate_math_precision(n) +@{ + return (1 != (1+(1/(2^(n-1))))) +@} +@c endfile +@end example + +Here is code that invokes the function in order to check +if arbitrary-precision arithmetic is available: + +@example +BEGIN @{ + # How many bits of mantissa precision are required + # for this program to function properly? + fpbits = 123 + + # We hope that we were invoked with MPFR enabled. If so, the + # following statement should configure calculations to our desired + # precision. + PREC = fpbits + + if (! adequate_math_precision(fpbits)) @{ + print("Error: insufficient computation precision available.\n" \ + "Try again with the -M argument?") > "/dev/stderr" + exit 1 + @} +@} +@end example + @node POSIX Floating Point Problems @section Standards Versus Existing Practice |