Bug 74662 - Large integers print in %e format even though %d format specified
Large integers print in %e format even though %d format specified
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: gawk (Show other bugs)
7.2
i686 Linux
medium Severity high
: ---
: ---
Assigned To: Florian La Roche
Brock Organ
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2002-09-29 23:33 EDT by jwitford
Modified: 2007-04-18 12:46 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-04-15 04:55:02 EDT
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 jwitford 2002-09-29 23:33:02 EDT
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 04:55:02 EDT
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.