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: minxian wang
Subject: Re: [bug-gawk] bug reports: [extreme value for scientific notation]
Date: Wed, 22 Apr 2015 11:35:45 -0400

Hi Andy,

Thank you very much ! I have updated my gawk version, now it works.

Thanks
Wallace
---------------------------------

On Tue, Apr 21, 2015 at 11:31 PM, Andrew J. Schorr <address@hidden> wrote:
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]