Bug 113423 - integer/float conversion problem in awk
Summary: integer/float conversion problem in awk
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: gawk
Version: rawhide
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Thomas Woerner
QA Contact: Brock Organ
URL:
Whiteboard:
: 112985 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2004-01-13 19:26 UTC by Rafael Araújo da Silva
Modified: 2007-11-30 22:10 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2004-01-14 13:24:32 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Rafael Araújo da Silva 2004-01-13 19:26:31 UTC
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 07:55:12 UTC
*** Bug 112985 has been marked as a duplicate of this bug. ***

Comment 2 Thomas Woerner 2004-01-14 10:58:37 UTC
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 13:22:57 UTC
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.