Determine the radix character used when interpreting numeric input, performing conversions between numeric and string values, and formatting numeric output. Regardless of locale, the period character (the decimal-point character of the POSIX locale) is the decimal-point character recognized in processing awk programs (including assignments in command line arguments).
POSIX erwartet also, dass man LC_NUMERIC respektiert.. ausser im Falle von awk und ich kann das in zwei von drei awks reproduzieren:
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Ich bin mir nicht sicher, ob Du gut genug gesucht hast.
POSIX awk:
A string value shall be converted to a numeric value by the equivalent of the following calls to functions defined by the ISO C standard:
setlocale(LC_NUMERIC, "");
numeric_value = atof(string_value);
sowie
LC_NUMERIC
Determine the radix character used when interpreting numeric input, performing conversions between numeric and string values, and formatting numeric output. Regardless of locale, the period character (the decimal-point character of the POSIX locale) is the decimal-point character recognized in processing awk programs (including assignments in command line arguments).
POSIX erwartet also, dass man LC_NUMERIC respektiert.. ausser im Falle von awk und ich kann das in zwei von drei awks reproduzieren:
$ echo 0.1 0.1 | LC_ALL=en_US.UTF-8 gawk '{print $1+$2}'
0.2
$ echo 0.1 0.1 | LC_ALL=de_DE.UTF-8 gawk '{print $1+$2}'
0.2
$ echo 0.1 0.1 | LC_ALL=en_US.UTF-8 nawk '{print $1+$2}'
0.2
$ echo 0.1 0.1 | LC_ALL=de_DE.UTF-8 nawk '{print $1+$2}'
0
$ echo 0.1 0.1 | LC_ALL=de_DE.UTF-8 mawk '{print $1+$2}'
0.2
$ echo 0.1 0.1 | LC_ALL=en_US.UTF-8 mawk '{print $1+$2}'
0.2
$ echo 0.1 0.1 | LC_ALL=en_US.UTF-8 gawk --use-lc-numeric '{print $1+$2}'
0.2
$ echo 0,1 0,1 | LC_ALL=en_US.UTF-8 gawk --use-lc-numeric '{print $1+$2}'
0
$ echo 0.1 0.1 | LC_ALL=de_DE.UTF-8 gawk --use-lc-numeric '{print $1+$2}'
0
$ echo 0,1 0,1 | LC_ALL=de_DE.UTF-8 gawk --use-lc-numeric '{print $1+$2}'
0,2
Bei nawk scheints ein Bug zu sein, welcher unterdessen Behoben sein sollte:
http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=42320
Überprüfe also, welches awk du wie verwendest.
p.s.
$ gawk --version
GNU Awk 3.1.8
Copyright (C) 1989, 1991-2010 Free Software Foundation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/.
LC_ALL, LC_NUMERIC ---- gleicher Effekt..