bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gawk] bug reports: [extreme value for scientific notation]


From: Andrew J. Schorr
Subject: Re: [bug-gawk] bug reports: [extreme value for scientific notation]
Date: Tue, 21 Apr 2015 23:31:48 -0400
User-agent: Mutt/1.5.23 (2014-03-12)

Hi,

On Tue, Apr 21, 2015 at 12:16:13PM -0400, minxian wang wrote:
> I met a very wired problem by using gwak(4.0.1) or awk(4.0.1), like below
> example:
> 
> printf '3.142e-321 123\n3.142e-32 234' | gawk  '{if($1<1e-3) print $0}'
> 
> we should expect two lines were outputted, but only the last line
> "3.142e-32 234" can be outputted.

You are running into the limits of IEEE 754 double-precision numbers:

   http://en.wikipedia.org/wiki/Double-precision_floating-point_format

   The 11 bit width of the exponent allows the representation of numbers with a
   decimal exponent between 10−308 and 10308, with full 15–17 decimal digits
   precision.

If you use the -M option to select MPFR floating-point values, you should get
the expected results:

bash-4.2$ printf '3.142e-321 123\n3.142e-32 234' | gawk -M '{if($1<1e-3) print 
$0}'
3.142e-321 123
3.142e-32 234

Regards,
Andy



reply via email to

[Prev in Thread] Current Thread [Next in Thread]