Export to GitHub

original-mawk - issue #23

mawk () on Debian 7.1 64 bits: math calculation is wrong


Posted on Nov 28, 2013 by Happy Bear

What steps will reproduce the problem? 1. with mawk (version ??) echo '26341277696 26341278720 47819259904' | awk '{ printf "%d", ($1/$2)*$3; }' 2147483647 (is wrong)

2.with gawk (version 1:4.0.1+dfsg-2.1) echo '26341277696 26341278720 47819259904' | awk '{ printf "%d", ($1/$2)*$3; }' 47819258045 (is correct)

  1. more details see https://github.com/rear/rear/issues/335

What is the expected output? What do you see instead? expected output is mentioned in step 2

What version of the product are you using? On what operating system? mawk () on Debian 7.1 64 bits

Please provide any additional information below.

Comment #1

Posted on Nov 29, 2013 by Swift Ox

This is a known limitation: mawk's format for %d is limited by the format. The limitation is done to improve performance.

You can get more precision using one of the floating formats (and can construct one which prints like a %d, e.g., by putting a ".0" on the end of the format).

Comment #2

Posted on Jun 5, 2014 by Swift Ox

(No comment was entered for this change.)

Comment #3

Posted on Jun 5, 2014 by Swift Ox

Comment deleted

Status: WontFix

Labels:
Type-Defect Priority-Low