Bug 74662 - Large integers print in %e format even though %d format specified
Summary: Large integers print in %e format even though %d format specified
Status: CLOSED RAWHIDE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gawk   
(Show other bugs)
Version: 7.2
Hardware: i686 Linux
medium
high
Target Milestone: ---
Assignee: Florian La Roche
QA Contact: Brock Organ
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2002-09-30 03:33 UTC by jwitford
Modified: 2007-04-18 16:46 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-04-15 08:55:02 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

Description jwitford 2002-09-30 03:33:02 UTC
From Bugzilla Helper:
User-Agent: Mozilla/4.79 [en] (Win98; U)

Description of problem:
BEGIN{
    printf "%d\n", int(5093500000))
}

produces output of "5.0935e+09"


Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1.run rhis:  awk 'BEGIN{printf("%d\n", 5093500000)}'
2.look at output
3.have another look at output because it is so weird.


Actual Results:  Output is "5.0935e+09".

 Hey! That isn't an integer!!


Expected Results:  5093500000


Additional info:

Also get same result with sprintf.
Even if you cast the value with int() get the same result.

Comment 1 Florian La Roche 2003-04-15 08:55:02 UTC
Copy of some google search on this:

Because gawk's
OFMT default is "%.6g"
change it: OFMT="%.17g" 
Or use printf 
gawk 'END {printf "%.10g\n", 4294967296 + 4294967296}' < /dev/null


Closing this now,

Florian La Roche




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