29 May 2012 21:42
VAX FP: awk: floating point exception: Floating point overflow
David Brownlee <abs <at> absd.org>
2012-05-29 19:42:29 GMT
2012-05-29 19:42:29 GMT
Today's slice of VAX fun comes courtesy of this little fragment
echo 12345678911234567892123456789312345678941234567895123456 \
| awk '{split($0,a);print a[1]}'
On most machines this outputs:
12345678911234567892123456789312345678941234567895123456
On the VAX: "awk: floating point exception: Floating point overflow"
This is generated by awk's lib.c "is_number()" calling strtod()
errno = 0;
r = strtod(s, &ep);
if (ep == s || errno == ERANGE)
return 0;
which traps in strtod.c:526 "dval(&rv) *= bigtens[j];" when the
string passed is too big to represent as a double.
The attached strtod_test.c demonstrates this for anyone who cares :)
strtod() has some ifdef VAX "vax_ovfl_check" but obviously its not
catching this case.
So, is this an issue with the default SIGFPE generation logic, or
should strtod() be handing this case and avoiding the potential
overflow?
(Continue reading)
RSS Feed