The beauty of awk
is that, using 1 single stream of integers jotted, it can simultaneously be generating multiple concurrent (and possibly cross-interacting) sequences with barely any code at all :
jot - -10 399 |
mawk2 '__+=($++NF+=__+=-($++NF+=(--$!_)*9^9-1)+($!_^=2))' CONVFMT='%.20g'
121 4261625501 -4261625380
100 12397455993 -3874204891
81 28281696469 -3486784402
64 59662756915 -3099363913
49 122037457303 -2711943424
36 246399437577 -2324522935
25 494735977625 -1937102446
16 991021637223 -1549681957
9 1983205535923 -1162261468
4 3967185912829 -774840979
1 7934759246149 -387420490
0 15869518492299 -1
1 31738649564111 387420488
4 63476524287249 774840977
9 126951886313041 1162261466
16 253902222944143 1549681955
25 507802508785867 1937102444
36 1015602693048837 2324522933
49 2031202674154301 2711943422
64 4062402248944755 3099363911
81 8124801011105191 3486784400
This is a less commonly known feature, but mawk-1
can directly generate formatted output without using printf()
or sprintf()
:
jot - -11111111555359 900729999999999 49987777777556 |
mawk '$++NF=_+=$!__' CONVFMT='%+\047\043 30.f' OFS='\t'
-11111111555359 -11,111,111,555,359.
38876666222197 +27,765,554,666,838.
88864443999753 +116,629,998,666,591.
138852221777309 +255,482,220,443,900.
188839999554865 +444,322,219,998,765.
238827777332421 +683,149,997,331,186.
288815555109977 +971,965,552,441,163.
338803332887533 +1,310,768,885,328,696.
388791110665089 +1,699,559,995,993,785.
438778888442645 +2,138,338,884,436,430.
488766666220201 +2,627,105,550,656,631.
538754443997757 +3,165,859,994,654,388.
588742221775313 +3,754,602,216,429,701.
638729999552869 +4,393,332,215,982,570.
688717777330425 +5,082,049,993,312,995.
738705555107981 +5,820,755,548,420,976.
788693332885537 +6,609,448,881,306,513.
838681110663093 +7,448,129,991,969,606.
888668888440649 +8,336,798,880,410,255.
With nawk
, one even more obscure feature is being able to print out the exact IEEE 754 double precision
floating point hex :
jot - .00001591111137777 \
9007299999.1111111111 123.990333333328 |
nawk '$++NF=_+=_+= cos(exp(log($!__)/1.1))' CONVFMT='[ %20.13p ]' OFS='\t' \_=1
0.00001591111137777 [ 0x400fffffffbf27f8 ]
123.99034924443937200 [ 0x401f1a2498670bcc ]
247.98068257776736800 [ 0x40313bd908775e35 ]
371.97101591109537821 [ 0x4040516a505a57a3 ]
495.96134924442338843 [ 0x4050b807540a1c3a ]
619.95168257775139864 [ 0x4060f800d1abb906 ]
743.94201591107935201 [ 0x407112ffc8adec4a ]
867.93234924440730538 [ 0x40810bab4a485ad9 ]
991.92268257773525875 [ 0x4091089e1149c279 ]
1115.91301591106321212 [ 0x40a10ac8cfb09c62 ]
1239.90334924439116548 [ 0x40b10a7bfa7fa42d ]
1363.89368257771911885 [ 0x40c109c2d1b9947c ]
1487.88401591104707222 [ 0x40d10a2644d5ab3b ]
gawk w/ GMP
is even more interesting - they're willing to provide comma-formatted hex on your behalf, plus strangely padding extra commas in the empty space to its left
=
jot - .000591111137777 90079.1111111111 123.990333333328 |
gawk -v PREC=20000 -nMbe '
$++NF = _ +=(15^16 * log($!__)/log(sqrt(10)))' \
CONVFMT='< 0x %\04724.12x >' OFS=' | ' \_=1
# rows skipped in the middle for illustration clarity
4339.662257777619743 | < 0x , ,4e6,007,2f4,08a,b93,8b3 >
4463.652591110947469 | < 0x , ,50f,967,27f,e5a,963,518 >
4835.623591110930647 | < 0x , ,58d,250,b65,a8d,45d,b79 >
7315.430257777485167 | < 0x , ,8eb,b36,ee9,fe6,149,da5 >
11779.082257777283303 | < 0x , ,f4b,c34,a75,82a,826,abb >
12151.053257777266481 | < 0x , ,fd7,3c2,25e,1ab,a09,bbf >
16738.695591110394162 | < 0x , 1,6b0,f3b,350,ed3,eca,c58 >
17978.598924443671422 | < 0x , 1,894,2f2,aba,a30,f63,bae >
20458.405591110225942 | < 0x , 1,c64,a40,87e,e35,4d4,896 >
23434.173591110091365 | < 0x , 2,108,186,96e,0dc,2ef,d46 >
31741.525924443049007 | < 0x , 2,e45,bae,b73,24f,981,637 >
32857.438924442998541 | < 0x , 3,014,3a7,b9e,daf,18c,c3e >
33849.361591109620349 | < 0x , 3,1b0,9b7,5f1,536,49c,74e >
41536.762257775939361 | < 0x , 3,e51,7c1,9b2,e74,516,220 >
45876.423924442409771 | < 0x , 4,58c,52d,078,edb,db4,4ba >
53067.863257775417878 | < 0x , 5,1aa,cf3,eed,33c,638,456 >
59391.370257775131904 | < 0x , 5,c73,38a,54d,b41,98d,a02 >
61127.234924441720068 | < 0x , 5,f6d,ce2,c40,117,6d2,6e7 >
66830.790257774875499 | < 0x , 6,944,fe1,378,9ea,235,7b0 >
71170.451924441600568 | < 0x , 7,0ce,de6,797,df3,009,35d >
76254.055591108335648 | < 0x , 7,9b0,f6d,03d,878,edf,97d >
83073.523924441760755 | < 0x , 8,5b0,aa9,7f7,a31,89a,f2e >
86669.243591108475812 | < 0x , 8,c0d,678,fa3,3b1,aad,f26 >
89149.050257775175851 | < 0x , 9,074,278,19d,4c7,443,a00 >
89769.001924441850861 | < 0x , 9,18e,464,ff9,0eb,ee4,4e1 >
but be weary of syntactical errors -
- this is a selection of what's being printed out to
STDOUT
,
- all
256
byte choices have been observed of what's being printed out, even if it's terminal window
=
jot 3000 |
gawk -Me ' _=$++NF=____+=$++NF=___-= $++NF=__+=$++NF=\
_^= exp(cos($++NF=______+=($1) %10 + 1))' \
____=-111111089 OFMT='%32c`'
char >>[ --[ U+ 2 | 2 (ASCII) freq >>[ 8 sumtotal >>[ 45151
char >>[ --[ U+ 4 | 4 (ASCII) freq >>[ 11 sumtotal >>[ 45166
char >>[ --[ U+ 14 | 20 (ASCII) freq >>[ 9 sumtotal >>[ 45301
char >>[ + --[ U+ 2B | 43 (ASCII) freq >>[ 9 sumtotal >>[ 60645
char >>[ --[ U+ 9 | 9 (ASCII) freq >>[ 12 sumtotal >>[ 45216
char >>[ 8 --[ U+ 38 | 56 (ASCII) freq >>[ 1682 sumtotal >>[ 82522
char >>[ Q --[ U+ 51 | 81 (ASCII) freq >>[ 6 sumtotal >>[ 85040
char >>[ Y --[ U+ 59 | 89 (ASCII) freq >>[ 8 sumtotal >>[ 85105
char >>[ g --[ U+ 67 | 103 (ASCII) freq >>[ 10 sumtotal >>[ 85212
char >>[ p --[ U+ 70 | 112 (ASCII) freq >>[ 7 sumtotal >>[ 85411
char >>[ v --[ U+ 76 | 118 (ASCII) freq >>[ 7 sumtotal >>[ 85462
char >>[ ? --[ \216 \x8E | 142 (8-bit byte) freq >>[ 15 sumtotal >>[ 85653
char >>[ ? --[ \222 \x92 | 146 (8-bit byte) freq >>[ 13 sumtotal >>[ 85698
char >>[ ? --[ \250 \xA8 | 168 (8-bit byte) freq >>[ 9 sumtotal >>[ 85967
char >>[ ? --[ \307 \xC7 | 199 (8-bit byte) freq >>[ 7 sumtotal >>[ 86345
char >>[ ? --[ \332 \xDA | 218 (8-bit byte) freq >>[ 69 sumtotal >>[ 86576
char >>[ ? --[ \352 \xEA | 234 (8-bit byte) freq >>[ 6 sumtotal >>[ 86702
char >>[ ? --[ \354 \xEC | 236 (8-bit byte) freq >>[ 5 sumtotal >>[ 86713
char >>[ ? --[ \372 \xFA | 250 (8-bit byte) freq >>[ 11 sumtotal >>[ 86823
char >>[ ? --[ \376 \xFE | 254 (8-bit byte) freq >>[ 9 sumtotal >>[ 86859