summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2015-05-30 23:42:51 -0400
committerArnold D. Robbins <arnold@skeeve.com>2015-05-30 23:42:51 -0400
commit501c2e5e720e3dbcb2e830c28037dd8b8d46bfcf (patch)
treee47fc4eded939744788371f2b26ddeb0c5d1f196
parent7ae0f019e5636657d449d20ac0546c3bc6ac1bb2 (diff)
downloadgawk-501c2e5e720e3dbcb2e830c28037dd8b8d46bfcf.tar.gz
Improve handling and doc of compl().
-rw-r--r--ChangeLog10
-rw-r--r--doc/ChangeLog4
-rw-r--r--doc/gawk.info606
-rw-r--r--doc/gawk.texi2
-rw-r--r--doc/gawktexi.in2
-rw-r--r--floatcomp.c25
6 files changed, 342 insertions, 307 deletions
diff --git a/ChangeLog b/ChangeLog
index 8d623ac0..da14af06 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2015-05-26 Paul Eggert <eggert@Penguin.CS.UCLA.EDU>
+
+ * floatcomp.c (count_trailing_zeros): New function.
+ This compiles to a single TZCNT instruction on the x86-64.
+ (adjust_uint): Use it to keep more high-order bits when
+ some of the lowest-order bits are zero. This implements
+ the documented behavior: "If the result cannot be represented
+ exactly as a C 'double', leading nonzero bits are removed one by
+ one until it can be represented exactly."
+
2015-05-26 Arnold D. Robbins <arnold@skeeve.com>
* regcomp.c: Fix offsets so error messages come out correct
diff --git a/doc/ChangeLog b/doc/ChangeLog
index f554d30a..1c9420d9 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,7 @@
+2015-05-30 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawktexi.in (Bitwise Functions): Update results of testbits.awk.
+
2015-05-19 Arnold D. Robbins <arnold@skeeve.com>
* 4.1.3: Release tar ball made.
diff --git a/doc/gawk.info b/doc/gawk.info
index 1991a3b7..8d328901 100644
--- a/doc/gawk.info
+++ b/doc/gawk.info
@@ -13258,7 +13258,7 @@ This program produces the following output when run:
-| 123 = 01111011
-| 0123 = 01010011
-| 0x99 = 10011001
- -| compl(0x99) = 0xffffff66 = 11111111111111111111111101100110
+ -| compl(0x99) = 0x3fffffffffff66 = 00111111111111111111111111111111111111111111111101100110
-| lshift(0x99, 2) = 0x264 = 0000001001100100
-| rshift(0x99, 2) = 0x26 = 00100110
@@ -34767,307 +34767,307 @@ Ref: Time Functions-Footnote-5557525
Ref: Time Functions-Footnote-6557752
Node: Bitwise Functions558018
Ref: table-bitwise-ops558612
-Ref: Bitwise Functions-Footnote-1562920
-Node: Type Functions563093
-Node: I18N Functions564249
-Node: User-defined565900
-Node: Definition Syntax566705
-Ref: Definition Syntax-Footnote-1572392
-Node: Function Example572463
-Ref: Function Example-Footnote-1575385
-Node: Function Caveats575407
-Node: Calling A Function575925
-Node: Variable Scope576883
-Node: Pass By Value/Reference579877
-Node: Return Statement583376
-Node: Dynamic Typing586355
-Node: Indirect Calls587285
-Ref: Indirect Calls-Footnote-1597536
-Node: Functions Summary597664
-Node: Library Functions600369
-Ref: Library Functions-Footnote-1603978
-Ref: Library Functions-Footnote-2604121
-Node: Library Names604292
-Ref: Library Names-Footnote-1607753
-Ref: Library Names-Footnote-2607976
-Node: General Functions608062
-Node: Strtonum Function609165
-Node: Assert Function612187
-Node: Round Function615513
-Node: Cliff Random Function617054
-Node: Ordinal Functions618070
-Ref: Ordinal Functions-Footnote-1621133
-Ref: Ordinal Functions-Footnote-2621385
-Node: Join Function621595
-Ref: Join Function-Footnote-1623365
-Node: Getlocaltime Function623565
-Node: Readfile Function627309
-Node: Shell Quoting629283
-Node: Data File Management630684
-Node: Filetrans Function631316
-Node: Rewind Function635413
-Node: File Checking636799
-Ref: File Checking-Footnote-1638133
-Node: Empty Files638334
-Node: Ignoring Assigns640313
-Node: Getopt Function641863
-Ref: Getopt Function-Footnote-1653333
-Node: Passwd Functions653533
-Ref: Passwd Functions-Footnote-1662374
-Node: Group Functions662462
-Ref: Group Functions-Footnote-1670361
-Node: Walking Arrays670568
-Node: Library Functions Summary673578
-Node: Library Exercises674984
-Node: Sample Programs676263
-Node: Running Examples677033
-Node: Clones677761
-Node: Cut Program678985
-Node: Egrep Program688706
-Ref: Egrep Program-Footnote-1696218
-Node: Id Program696328
-Node: Split Program700008
-Ref: Split Program-Footnote-1703467
-Node: Tee Program703596
-Node: Uniq Program706386
-Node: Wc Program713812
-Ref: Wc Program-Footnote-1718067
-Node: Miscellaneous Programs718161
-Node: Dupword Program719374
-Node: Alarm Program721404
-Node: Translate Program726259
-Ref: Translate Program-Footnote-1730824
-Node: Labels Program731094
-Ref: Labels Program-Footnote-1734445
-Node: Word Sorting734529
-Node: History Sorting738601
-Node: Extract Program740436
-Node: Simple Sed747967
-Node: Igawk Program751041
-Ref: Igawk Program-Footnote-1765372
-Ref: Igawk Program-Footnote-2765574
-Ref: Igawk Program-Footnote-3765696
-Node: Anagram Program765811
-Node: Signature Program768873
-Node: Programs Summary770120
-Node: Programs Exercises771335
-Ref: Programs Exercises-Footnote-1775464
-Node: Advanced Features775555
-Node: Nondecimal Data777545
-Node: Array Sorting779136
-Node: Controlling Array Traversal779836
-Ref: Controlling Array Traversal-Footnote-1788205
-Node: Array Sorting Functions788323
-Ref: Array Sorting Functions-Footnote-1792210
-Node: Two-way I/O792406
-Ref: Two-way I/O-Footnote-1797357
-Ref: Two-way I/O-Footnote-2797544
-Node: TCP/IP Networking797626
-Node: Profiling800533
-Node: Advanced Features Summary808072
-Node: Internationalization810008
-Node: I18N and L10N811488
-Node: Explaining gettext812175
-Ref: Explaining gettext-Footnote-1817198
-Ref: Explaining gettext-Footnote-2817383
-Node: Programmer i18n817548
-Ref: Programmer i18n-Footnote-1822404
-Node: Translator i18n822453
-Node: String Extraction823247
-Ref: String Extraction-Footnote-1824380
-Node: Printf Ordering824466
-Ref: Printf Ordering-Footnote-1827252
-Node: I18N Portability827316
-Ref: I18N Portability-Footnote-1829772
-Node: I18N Example829835
-Ref: I18N Example-Footnote-1832641
-Node: Gawk I18N832714
-Node: I18N Summary833359
-Node: Debugger834700
-Node: Debugging835722
-Node: Debugging Concepts836163
-Node: Debugging Terms837972
-Node: Awk Debugging840547
-Node: Sample Debugging Session841453
-Node: Debugger Invocation841987
-Node: Finding The Bug843373
-Node: List of Debugger Commands849851
-Node: Breakpoint Control851184
-Node: Debugger Execution Control854878
-Node: Viewing And Changing Data858240
-Node: Execution Stack861614
-Node: Debugger Info863251
-Node: Miscellaneous Debugger Commands867322
-Node: Readline Support872331
-Node: Limitations873227
-Node: Debugging Summary875336
-Node: Arbitrary Precision Arithmetic876509
-Node: Computer Arithmetic877925
-Ref: table-numeric-ranges881516
-Ref: Computer Arithmetic-Footnote-1882238
-Node: Math Definitions882295
-Ref: table-ieee-formats885609
-Ref: Math Definitions-Footnote-1886212
-Node: MPFR features886317
-Node: FP Math Caution887990
-Ref: FP Math Caution-Footnote-1889062
-Node: Inexactness of computations889431
-Node: Inexact representation890391
-Node: Comparing FP Values891751
-Node: Errors accumulate892833
-Node: Getting Accuracy894266
-Node: Try To Round896976
-Node: Setting precision897875
-Ref: table-predefined-precision-strings898572
-Node: Setting the rounding mode900402
-Ref: table-gawk-rounding-modes900776
-Ref: Setting the rounding mode-Footnote-1904184
-Node: Arbitrary Precision Integers904363
-Ref: Arbitrary Precision Integers-Footnote-1907347
-Node: POSIX Floating Point Problems907496
-Ref: POSIX Floating Point Problems-Footnote-1911378
-Node: Floating point summary911416
-Node: Dynamic Extensions913606
-Node: Extension Intro915159
-Node: Plugin License916425
-Node: Extension Mechanism Outline917222
-Ref: figure-load-extension917661
-Ref: figure-register-new-function919226
-Ref: figure-call-new-function920318
-Node: Extension API Description922381
-Node: Extension API Functions Introduction923831
-Node: General Data Types928643
-Ref: General Data Types-Footnote-1934598
-Node: Memory Allocation Functions934897
-Ref: Memory Allocation Functions-Footnote-1937742
-Node: Constructor Functions937841
-Node: Registration Functions939586
-Node: Extension Functions940271
-Node: Exit Callback Functions942570
-Node: Extension Version String943820
-Node: Input Parsers944483
-Node: Output Wrappers954368
-Node: Two-way processors958880
-Node: Printing Messages961144
-Ref: Printing Messages-Footnote-1962220
-Node: Updating 'ERRNO'962373
-Node: Requesting Values963114
-Ref: table-value-types-returned963853
-Node: Accessing Parameters964736
-Node: Symbol Table Access965972
-Node: Symbol table by name966484
-Node: Symbol table by cookie968505
-Ref: Symbol table by cookie-Footnote-1972654
-Node: Cached values972718
-Ref: Cached values-Footnote-1976219
-Node: Array Manipulation976310
-Ref: Array Manipulation-Footnote-1977409
-Node: Array Data Types977446
-Ref: Array Data Types-Footnote-1980104
-Node: Array Functions980196
-Node: Flattening Arrays984055
-Node: Creating Arrays990963
-Node: Extension API Variables995735
-Node: Extension Versioning996371
-Node: Extension API Informational Variables998262
-Node: Extension API Boilerplate999326
-Node: Finding Extensions1003140
-Node: Extension Example1003700
-Node: Internal File Description1004498
-Node: Internal File Ops1008578
-Ref: Internal File Ops-Footnote-11020340
-Node: Using Internal File Ops1020480
-Ref: Using Internal File Ops-Footnote-11022863
-Node: Extension Samples1023138
-Node: Extension Sample File Functions1024667
-Node: Extension Sample Fnmatch1032316
-Node: Extension Sample Fork1033803
-Node: Extension Sample Inplace1035021
-Node: Extension Sample Ord1037107
-Node: Extension Sample Readdir1037943
-Ref: table-readdir-file-types1038832
-Node: Extension Sample Revout1039637
-Node: Extension Sample Rev2way1040226
-Node: Extension Sample Read write array1040966
-Node: Extension Sample Readfile1042908
-Node: Extension Sample Time1044003
-Node: Extension Sample API Tests1045351
-Node: gawkextlib1045843
-Node: Extension summary1048267
-Node: Extension Exercises1051959
-Node: Language History1053456
-Node: V7/SVR3.11055112
-Node: SVR41057265
-Node: POSIX1058699
-Node: BTL1060079
-Node: POSIX/GNU1060809
-Node: Feature History1066330
-Node: Common Extensions1079660
-Node: Ranges and Locales1080943
-Ref: Ranges and Locales-Footnote-11085559
-Ref: Ranges and Locales-Footnote-21085586
-Ref: Ranges and Locales-Footnote-31085821
-Node: Contributors1086042
-Node: History summary1091611
-Node: Installation1092991
-Node: Gawk Distribution1093936
-Node: Getting1094420
-Node: Extracting1095243
-Node: Distribution contents1096881
-Node: Unix Installation1102634
-Node: Quick Installation1103250
-Node: Additional Configuration Options1105677
-Node: Configuration Philosophy1107481
-Node: Non-Unix Installation1109851
-Node: PC Installation1110309
-Node: PC Binary Installation1111629
-Node: PC Compiling1113481
-Ref: PC Compiling-Footnote-11116505
-Node: PC Testing1116614
-Node: PC Using1117794
-Node: Cygwin1121908
-Node: MSYS1122678
-Node: VMS Installation1123179
-Node: VMS Compilation1123970
-Ref: VMS Compilation-Footnote-11125200
-Node: VMS Dynamic Extensions1125258
-Node: VMS Installation Details1126943
-Node: VMS Running1129196
-Node: VMS GNV1132037
-Node: VMS Old Gawk1132772
-Node: Bugs1133243
-Node: Other Versions1137357
-Node: Installation summary1143831
-Node: Notes1144889
-Node: Compatibility Mode1145754
-Node: Additions1146536
-Node: Accessing The Source1147461
-Node: Adding Code1148897
-Node: New Ports1155052
-Node: Derived Files1159540
-Ref: Derived Files-Footnote-11165025
-Ref: Derived Files-Footnote-21165060
-Ref: Derived Files-Footnote-31165658
-Node: Future Extensions1165772
-Node: Implementation Limitations1166430
-Node: Extension Design1167613
-Node: Old Extension Problems1168767
-Ref: Old Extension Problems-Footnote-11170285
-Node: Extension New Mechanism Goals1170342
-Ref: Extension New Mechanism Goals-Footnote-11173706
-Node: Extension Other Design Decisions1173895
-Node: Extension Future Growth1176008
-Node: Old Extension Mechanism1176844
-Node: Notes summary1178607
-Node: Basic Concepts1179789
-Node: Basic High Level1180470
-Ref: figure-general-flow1180752
-Ref: figure-process-flow1181437
-Ref: Basic High Level-Footnote-11184738
-Node: Basic Data Typing1184923
-Node: Glossary1188251
-Node: Copying1220197
-Node: GNU Free Documentation License1257736
-Node: Index1282854
+Ref: Bitwise Functions-Footnote-1562950
+Node: Type Functions563123
+Node: I18N Functions564279
+Node: User-defined565930
+Node: Definition Syntax566735
+Ref: Definition Syntax-Footnote-1572422
+Node: Function Example572493
+Ref: Function Example-Footnote-1575415
+Node: Function Caveats575437
+Node: Calling A Function575955
+Node: Variable Scope576913
+Node: Pass By Value/Reference579907
+Node: Return Statement583406
+Node: Dynamic Typing586385
+Node: Indirect Calls587315
+Ref: Indirect Calls-Footnote-1597566
+Node: Functions Summary597694
+Node: Library Functions600399
+Ref: Library Functions-Footnote-1604008
+Ref: Library Functions-Footnote-2604151
+Node: Library Names604322
+Ref: Library Names-Footnote-1607783
+Ref: Library Names-Footnote-2608006
+Node: General Functions608092
+Node: Strtonum Function609195
+Node: Assert Function612217
+Node: Round Function615543
+Node: Cliff Random Function617084
+Node: Ordinal Functions618100
+Ref: Ordinal Functions-Footnote-1621163
+Ref: Ordinal Functions-Footnote-2621415
+Node: Join Function621625
+Ref: Join Function-Footnote-1623395
+Node: Getlocaltime Function623595
+Node: Readfile Function627339
+Node: Shell Quoting629313
+Node: Data File Management630714
+Node: Filetrans Function631346
+Node: Rewind Function635443
+Node: File Checking636829
+Ref: File Checking-Footnote-1638163
+Node: Empty Files638364
+Node: Ignoring Assigns640343
+Node: Getopt Function641893
+Ref: Getopt Function-Footnote-1653363
+Node: Passwd Functions653563
+Ref: Passwd Functions-Footnote-1662404
+Node: Group Functions662492
+Ref: Group Functions-Footnote-1670391
+Node: Walking Arrays670598
+Node: Library Functions Summary673608
+Node: Library Exercises675014
+Node: Sample Programs676293
+Node: Running Examples677063
+Node: Clones677791
+Node: Cut Program679015
+Node: Egrep Program688736
+Ref: Egrep Program-Footnote-1696248
+Node: Id Program696358
+Node: Split Program700038
+Ref: Split Program-Footnote-1703497
+Node: Tee Program703626
+Node: Uniq Program706416
+Node: Wc Program713842
+Ref: Wc Program-Footnote-1718097
+Node: Miscellaneous Programs718191
+Node: Dupword Program719404
+Node: Alarm Program721434
+Node: Translate Program726289
+Ref: Translate Program-Footnote-1730854
+Node: Labels Program731124
+Ref: Labels Program-Footnote-1734475
+Node: Word Sorting734559
+Node: History Sorting738631
+Node: Extract Program740466
+Node: Simple Sed747997
+Node: Igawk Program751071
+Ref: Igawk Program-Footnote-1765402
+Ref: Igawk Program-Footnote-2765604
+Ref: Igawk Program-Footnote-3765726
+Node: Anagram Program765841
+Node: Signature Program768903
+Node: Programs Summary770150
+Node: Programs Exercises771365
+Ref: Programs Exercises-Footnote-1775494
+Node: Advanced Features775585
+Node: Nondecimal Data777575
+Node: Array Sorting779166
+Node: Controlling Array Traversal779866
+Ref: Controlling Array Traversal-Footnote-1788235
+Node: Array Sorting Functions788353
+Ref: Array Sorting Functions-Footnote-1792240
+Node: Two-way I/O792436
+Ref: Two-way I/O-Footnote-1797387
+Ref: Two-way I/O-Footnote-2797574
+Node: TCP/IP Networking797656
+Node: Profiling800563
+Node: Advanced Features Summary808102
+Node: Internationalization810038
+Node: I18N and L10N811518
+Node: Explaining gettext812205
+Ref: Explaining gettext-Footnote-1817228
+Ref: Explaining gettext-Footnote-2817413
+Node: Programmer i18n817578
+Ref: Programmer i18n-Footnote-1822434
+Node: Translator i18n822483
+Node: String Extraction823277
+Ref: String Extraction-Footnote-1824410
+Node: Printf Ordering824496
+Ref: Printf Ordering-Footnote-1827282
+Node: I18N Portability827346
+Ref: I18N Portability-Footnote-1829802
+Node: I18N Example829865
+Ref: I18N Example-Footnote-1832671
+Node: Gawk I18N832744
+Node: I18N Summary833389
+Node: Debugger834730
+Node: Debugging835752
+Node: Debugging Concepts836193
+Node: Debugging Terms838002
+Node: Awk Debugging840577
+Node: Sample Debugging Session841483
+Node: Debugger Invocation842017
+Node: Finding The Bug843403
+Node: List of Debugger Commands849881
+Node: Breakpoint Control851214
+Node: Debugger Execution Control854908
+Node: Viewing And Changing Data858270
+Node: Execution Stack861644
+Node: Debugger Info863281
+Node: Miscellaneous Debugger Commands867352
+Node: Readline Support872361
+Node: Limitations873257
+Node: Debugging Summary875366
+Node: Arbitrary Precision Arithmetic876539
+Node: Computer Arithmetic877955
+Ref: table-numeric-ranges881546
+Ref: Computer Arithmetic-Footnote-1882268
+Node: Math Definitions882325
+Ref: table-ieee-formats885639
+Ref: Math Definitions-Footnote-1886242
+Node: MPFR features886347
+Node: FP Math Caution888020
+Ref: FP Math Caution-Footnote-1889092
+Node: Inexactness of computations889461
+Node: Inexact representation890421
+Node: Comparing FP Values891781
+Node: Errors accumulate892863
+Node: Getting Accuracy894296
+Node: Try To Round897006
+Node: Setting precision897905
+Ref: table-predefined-precision-strings898602
+Node: Setting the rounding mode900432
+Ref: table-gawk-rounding-modes900806
+Ref: Setting the rounding mode-Footnote-1904214
+Node: Arbitrary Precision Integers904393
+Ref: Arbitrary Precision Integers-Footnote-1907377
+Node: POSIX Floating Point Problems907526
+Ref: POSIX Floating Point Problems-Footnote-1911408
+Node: Floating point summary911446
+Node: Dynamic Extensions913636
+Node: Extension Intro915189
+Node: Plugin License916455
+Node: Extension Mechanism Outline917252
+Ref: figure-load-extension917691
+Ref: figure-register-new-function919256
+Ref: figure-call-new-function920348
+Node: Extension API Description922411
+Node: Extension API Functions Introduction923861
+Node: General Data Types928673
+Ref: General Data Types-Footnote-1934628
+Node: Memory Allocation Functions934927
+Ref: Memory Allocation Functions-Footnote-1937772
+Node: Constructor Functions937871
+Node: Registration Functions939616
+Node: Extension Functions940301
+Node: Exit Callback Functions942600
+Node: Extension Version String943850
+Node: Input Parsers944513
+Node: Output Wrappers954398
+Node: Two-way processors958910
+Node: Printing Messages961174
+Ref: Printing Messages-Footnote-1962250
+Node: Updating 'ERRNO'962403
+Node: Requesting Values963144
+Ref: table-value-types-returned963883
+Node: Accessing Parameters964766
+Node: Symbol Table Access966002
+Node: Symbol table by name966514
+Node: Symbol table by cookie968535
+Ref: Symbol table by cookie-Footnote-1972684
+Node: Cached values972748
+Ref: Cached values-Footnote-1976249
+Node: Array Manipulation976340
+Ref: Array Manipulation-Footnote-1977439
+Node: Array Data Types977476
+Ref: Array Data Types-Footnote-1980134
+Node: Array Functions980226
+Node: Flattening Arrays984085
+Node: Creating Arrays990993
+Node: Extension API Variables995765
+Node: Extension Versioning996401
+Node: Extension API Informational Variables998292
+Node: Extension API Boilerplate999356
+Node: Finding Extensions1003170
+Node: Extension Example1003730
+Node: Internal File Description1004528
+Node: Internal File Ops1008608
+Ref: Internal File Ops-Footnote-11020370
+Node: Using Internal File Ops1020510
+Ref: Using Internal File Ops-Footnote-11022893
+Node: Extension Samples1023168
+Node: Extension Sample File Functions1024697
+Node: Extension Sample Fnmatch1032346
+Node: Extension Sample Fork1033833
+Node: Extension Sample Inplace1035051
+Node: Extension Sample Ord1037137
+Node: Extension Sample Readdir1037973
+Ref: table-readdir-file-types1038862
+Node: Extension Sample Revout1039667
+Node: Extension Sample Rev2way1040256
+Node: Extension Sample Read write array1040996
+Node: Extension Sample Readfile1042938
+Node: Extension Sample Time1044033
+Node: Extension Sample API Tests1045381
+Node: gawkextlib1045873
+Node: Extension summary1048297
+Node: Extension Exercises1051989
+Node: Language History1053486
+Node: V7/SVR3.11055142
+Node: SVR41057295
+Node: POSIX1058729
+Node: BTL1060109
+Node: POSIX/GNU1060839
+Node: Feature History1066360
+Node: Common Extensions1079690
+Node: Ranges and Locales1080973
+Ref: Ranges and Locales-Footnote-11085589
+Ref: Ranges and Locales-Footnote-21085616
+Ref: Ranges and Locales-Footnote-31085851
+Node: Contributors1086072
+Node: History summary1091641
+Node: Installation1093021
+Node: Gawk Distribution1093966
+Node: Getting1094450
+Node: Extracting1095273
+Node: Distribution contents1096911
+Node: Unix Installation1102664
+Node: Quick Installation1103280
+Node: Additional Configuration Options1105707
+Node: Configuration Philosophy1107511
+Node: Non-Unix Installation1109881
+Node: PC Installation1110339
+Node: PC Binary Installation1111659
+Node: PC Compiling1113511
+Ref: PC Compiling-Footnote-11116535
+Node: PC Testing1116644
+Node: PC Using1117824
+Node: Cygwin1121938
+Node: MSYS1122708
+Node: VMS Installation1123209
+Node: VMS Compilation1124000
+Ref: VMS Compilation-Footnote-11125230
+Node: VMS Dynamic Extensions1125288
+Node: VMS Installation Details1126973
+Node: VMS Running1129226
+Node: VMS GNV1132067
+Node: VMS Old Gawk1132802
+Node: Bugs1133273
+Node: Other Versions1137387
+Node: Installation summary1143861
+Node: Notes1144919
+Node: Compatibility Mode1145784
+Node: Additions1146566
+Node: Accessing The Source1147491
+Node: Adding Code1148927
+Node: New Ports1155082
+Node: Derived Files1159570
+Ref: Derived Files-Footnote-11165055
+Ref: Derived Files-Footnote-21165090
+Ref: Derived Files-Footnote-31165688
+Node: Future Extensions1165802
+Node: Implementation Limitations1166460
+Node: Extension Design1167643
+Node: Old Extension Problems1168797
+Ref: Old Extension Problems-Footnote-11170315
+Node: Extension New Mechanism Goals1170372
+Ref: Extension New Mechanism Goals-Footnote-11173736
+Node: Extension Other Design Decisions1173925
+Node: Extension Future Growth1176038
+Node: Old Extension Mechanism1176874
+Node: Notes summary1178637
+Node: Basic Concepts1179819
+Node: Basic High Level1180500
+Ref: figure-general-flow1180782
+Ref: figure-process-flow1181467
+Ref: Basic High Level-Footnote-11184768
+Node: Basic Data Typing1184953
+Node: Glossary1188281
+Node: Copying1220227
+Node: GNU Free Documentation License1257766
+Node: Index1282884

End Tag Table
diff --git a/doc/gawk.texi b/doc/gawk.texi
index 18ef080b..57a2f893 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -19175,7 +19175,7 @@ $ @kbd{gawk -f testbits.awk}
@print{} 123 = 01111011
@print{} 0123 = 01010011
@print{} 0x99 = 10011001
-@print{} compl(0x99) = 0xffffff66 = 11111111111111111111111101100110
+@print{} compl(0x99) = 0x3fffffffffff66 = 00111111111111111111111111111111111111111111111101100110
@print{} lshift(0x99, 2) = 0x264 = 0000001001100100
@print{} rshift(0x99, 2) = 0x26 = 00100110
@end example
diff --git a/doc/gawktexi.in b/doc/gawktexi.in
index 0066593f..03857f1e 100644
--- a/doc/gawktexi.in
+++ b/doc/gawktexi.in
@@ -18296,7 +18296,7 @@ $ @kbd{gawk -f testbits.awk}
@print{} 123 = 01111011
@print{} 0123 = 01010011
@print{} 0x99 = 10011001
-@print{} compl(0x99) = 0xffffff66 = 11111111111111111111111101100110
+@print{} compl(0x99) = 0x3fffffffffff66 = 00111111111111111111111111111111111111111111111101100110
@print{} lshift(0x99, 2) = 0x264 = 0000001001100100
@print{} rshift(0x99, 2) = 0x26 = 00100110
@end example
diff --git a/floatcomp.c b/floatcomp.c
index 16a6d88e..d8d35694 100644
--- a/floatcomp.c
+++ b/floatcomp.c
@@ -71,6 +71,20 @@ Please port the following code to your weird host;
#define AWKNUM_FRACTION_BITS (AWKNUM_MANT_DIG * (FLT_RADIX == 2 ? 1 : 4))
#define DBL_FRACTION_BITS (DBL_MANT_DIG * (FLT_RADIX == 2 ? 1 : 4))
+/* Return the number of trailing zeros in N. N must be nonzero. */
+static int
+count_trailing_zeros(uintmax_t n)
+{
+#if 3 < (__GNUC__ + (4 <= __GNUC_MINOR__)) && UINTMAX_MAX <= ULLONG_MAX
+ return __builtin_ctzll(n);
+#else
+ int i = 0;
+ for (; (n & 3) == 0; n >>= 2)
+ i += 2;
+ return i + (1 & ~n);
+#endif
+}
+
/* adjust_uint --- fiddle with values, ask Paul Eggert to explain */
uintmax_t
@@ -84,8 +98,15 @@ adjust_uint(uintmax_t n)
* This is more desirable in practice, since it means the user sees
* integers that are the same width as the AWKNUM fractions.
*/
- if (AWKNUM_FRACTION_BITS < CHAR_BIT * sizeof n)
- n &= ((uintmax_t) 1 << AWKNUM_FRACTION_BITS) - 1;
+ int wordbits = CHAR_BIT * sizeof n;
+ if (AWKNUM_FRACTION_BITS < wordbits) {
+ uintmax_t one = 1;
+ uintmax_t sentinel = one << (wordbits - AWKNUM_FRACTION_BITS);
+ int shift = count_trailing_zeros(n | sentinel);
+ uintmax_t mask = (one << AWKNUM_FRACTION_BITS) - 1;
+
+ n &= mask << shift;
+ }
return n;
}