Bug 74662

Summary: Large integers print in %e format even though %d format specified
Product: [Retired] Red Hat Linux Reporter: jwitford
Component: gawkAssignee: Florian La Roche <laroche>
Status: CLOSED RAWHIDE QA Contact: Brock Organ <borgan>
Severity: high Docs Contact:
Priority: medium    
Version: 7.2   
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
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: --- Target Upstream Version:
Embargoed:

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