$ echo "111111111 * 111111111" | bc -l
12345678987654321
$ perl -le 'print 111111111 * 111111111'
12345678987654321
$ python -c "print 111111111 * 111111111"
12345678987654321
(bash/zsh - same results)
$ echo $((111111111 * 111111111))
12345678987654321
$ awk 'BEGIN {printf "%.0f", '"111111111 * 111111111"'}'
12345678987654320
Awk uses double-precision floating-point numbers to represent all numeric values
so not all numeric values can be represented exactly. See
http://www.gnu.org/software/gawk/manual/gawk.html#Floating-Point-Issues.
Ed.
I think what gets me about these so called examples is the OP
ASKED for a floating point result but only with awk : <
perl -le 'printf "%.0f", 111111111 * 111111111'
gives the same result as awk does..
And in this particular case
awk 'BEGIN {print (111111111*111111111)}'
gives the "right" answer.
That depends on which awk, which OS, etc.:
on cygwin on Windows XP:
$ gawk 'BEGIN {print (111111111*111111111); exit}'
12345678987654320
on Solaris:
$ /usr/bin/awk 'BEGIN {print (111111111*111111111); exit}'
12345678987654320
$ nawk 'BEGIN {print (111111111*111111111); exit}'
12345678987654320
$ /usr/xpg4/bin/awk 'BEGIN {print (111111111*111111111); exit}'
12345678987654321
$ gawk 'BEGIN {print (111111111*111111111); exit}'
1.23457e+16
$ gawk 'BEGIN {printf "%.0f\n", (111111111*111111111); exit}'
12345678987654320
Regards,
Ed.
Indeed and thanks - I put the word right in quotes for a reason : >
My test was on Solaris too where I alias awk to /usr/xpg4/bin/awk