Bug 113423 - integer/float conversion problem in awk
integer/float conversion problem in awk
Status: CLOSED CURRENTRELEASE
Product: Fedora
Classification: Fedora
Component: gawk (Show other bugs)
rawhide
All Linux
medium Severity medium
: ---
: ---
Assigned To: Thomas Woerner
Brock Organ
:
: 112985 (view as bug list)
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2004-01-13 14:26 EST by Rafael Araújo da Silva
Modified: 2007-11-30 17:10 EST (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-01-14 08:24:32 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Rafael Araújo da Silva 2004-01-13 14:26:31 EST
From Bugzilla Helper:

Description of problem:

gawk-3.1.1-9:
$ echo 123.456 | awk '{print int($1*1000)}'
$ 123456  OK!

gawk-3.1.3-(3,4 and 5):
$ echo 123.456 | awk '{print int($1*1000)}'
$ 123000  It looks as a bug

Version-Release number of selected component (if applicable):
gawk-3.1.3-(3,4 and 5)

How reproducible:
Always

Steps to Reproduce:
1.$ echo 123.456 | awk '{print int($1*1000)}'
 
Actual Results:  123000

Expected Results:  123456

Additional info:

http://mail.gnu.org/archive/html/bug-gnu-utils/2003-09/msg01070.html
Comment 1 Florian La Roche 2004-01-14 02:55:12 EST
*** Bug 112985 has been marked as a duplicate of this bug. ***
Comment 2 Thomas Woerner 2004-01-14 05:58:37 EST
This seems to be a locale problem. Can it be, that 123.456 is no valid
floting point number for your locale? I think your locale is pt_BR.

Please use 'echo $LANG' to get your locale.

I think you have two solutions:

1) use 123,456 (valid floating point number for pt_BR)
2) set LANG=C: echo 123.456 | LANG=C awk '{print int($1*1000)}'
Comment 3 Rafael Araújo da Silva 2004-01-14 08:22:57 EST
You're right! Gawk-3.1.1 ignores language support and point is 
decimal separator. With gawk-3.1.3 decimal separator is comma and not 
point.

I´ve tried this

$rpm -ivh gawk-3.1.1-9.i386.rpm
$echo $LANG
pt_BR
$echo "123.456" | awk '{print int($1*1000)}'
123456
$echo "123,456" | awk '{print int($1*1000)}'
123000
$rpm -Uvh gawk-3.1.3-5.i386.rpm
$echo "123.456" | awk '{print int($1*1000)}'
123000
$echo "123,456" | awk '{print int($1*1000)}'
123456
$echo "123.456" | LANG=C awk '{print int($1*1000)}'
123456

Thanks!

Note You need to log in before you can comment on or make changes to this bug.