bug-gawk
[Top][All Lists]
Advanced

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

Re: GAWK 5.1.0 doesn't work with 64bit numbers


From: arnold
Subject: Re: GAWK 5.1.0 doesn't work with 64bit numbers
Date: Sun, 21 Mar 2021 08:21:23 -0600
User-agent: Heirloom mailx 12.5 7/5/10

Hello.

Thank you for taking the time to send in a report.

As Nelson Beebe has already answered, this is not a bug. It is clearly
documented that numbers in awk are C double precision floating point
values, and as he described, there are thus only 53 bits of precision.

You may use gawk's -M option to get floating point values of higher
precision (by way of the MPFR and GMP libraries):

$ gawk -M 'BEGIN {
> x0 = 0x736f6d6570736575
> printf("%X\n", x0)
> }'
736F6D6570736575

Hope this helps,

Arnold

uliriehm@web.de wrote:

> Dear Mr. Robbins.
>
> I'm running GAWK 5.1.0. This code doesn't work as expected:
>
> BEGIN {
>     # "somepseudorandomlygeneratedbytes"
>     x0 = 0x736f6d6570736575
>     x1 = 0x646f72616e646f6d
>     x2 = 0x6c7967656e657261
>     x3 = 0x7465646279746573
>     printf("%X\n", x0)
>     printf("%X\n", x1)
>     printf("%X\n", x2)
>     printf("%X\n", x3)
> }
>
> The output of this code is:
>
> 736F6D6570736400
> 646F72616E647000
> 6C7967656E657000
> 7465646279746400
>
> This is a bug!
>
> Hans Riehm



reply via email to

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