Hello,
I did this test with Windows 7. I get similar results when running gawk 4.2.1 with cygwin.
0 0
0.3 0.3
1e+30 1000000000000000019884624838656
1.2e+301 12000000000000000630057123062453042984453620000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
1.2e+311 0
1.2e+321 0
1.2e+331 0
1.2e+931 0
1.2e+9999 0
1.2e+9999999 0
I would argue that the result should be 'inf' since the input string looks like a number. Zero should be the decoding result when there is no leading number in the string but there are leading numbers.
There are lots of examples in which gawk will print 'inf' or 'nan'.
print -log(0) # inf
In this case it is the result of numeric function rather than the decoding of a field. I would argue that the results should be consistent in behavior.
You are right in that printing 'inf' is problematic since one cannot read it back in again and have it decoded again as 'infinity'. This is true with fields and with math functions.
+inf
-inf
This 'round-about' problem could be solved by outputting the sign to indicate it is numeric. On input '+inf' would decode to positive infinity and 'inf' would be just a string.
Thanks. Dan.