bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

decimal point vs. comma


From: Bohdan Milar
Subject: decimal point vs. comma
Date: Thu, 08 Sep 2005 00:24:17 +0200
User-agent: Mozilla Thunderbird 1.0.2-6 (X11/20050513)

Hi,

I use gawk to process several accounting books with thousands of entries. Everything went well until 3.1.3 where (as I found in the NEWS file) "Gawk now follows POSIX in handling of local numeric formats for
input, output and number/string conversions".

But this brought many problems, not only for me. I use Czech locales where offical decimal separator is "," and not ".", but for many reasons "." is commonly used (including the accounting operations). So now my Bash script for accounting analyses does not work correctly, e.g.

echo "sss 12.5 2.5" |awk '{print $2+$3}'
14

:-(

In addition gawk uses different rules for external and internal formats. So if I want to do 12,5 + 3,5 I must write

echo "sss 12,5" |awk '{print $2+2.5}'
15

because

echo "sss 12,5" |awk '{print $2+2,5}'
14,5 5

and

echo "sss 12.5" |awk '{print $2+2.5}'
14,5

I think this is not correct. I would prefer my software behaving consistently. I suppose to add a --locale parametr or something like that to turn on that strange behaviour and let default values on the previous state. I also need the compatibility with older systems where newer versions of Gawk have not yet been ported, but I use my script on them.

Best regards,

Bohdan Milar
Liberix
http:/www.liberix.cz





reply via email to

[Prev in Thread] Current Thread [Next in Thread]