bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: Is this abug or feature?


From: Paul Eggert
Subject: Re: Is this abug or feature?
Date: Thu, 3 May 2001 01:44:00 -0700 (PDT)

> From: Aharon Robbins <address@hidden>
> Date: Thu, 3 May 2001 10:06:08 +0300
> 
> The answer is "it's a feature."  All numbers in awk are double precision
> floating point.  When using an octal or hexadecimal output format, if
> the number is too big to fit into an unsigned long, gawk switches to %g
> format so that the output at least makes sense as a number.

Here's an idea for improving things a bit: use "uintmax_t" if it is
available.  This is the C99 type for the longest integer supported by
in the C implementation.  It has to be at least 64 bits long, and this
will suffice to print more integers than the 32 bits that is typical
for 'long'.  Older implementations don't support uintmax_t, but it can
be emulated by "unsigned long long" if available and by "unsigned
long" otherwise (e.g. see fileutils 4.1 for one way to do this).

The latest POSIX draft (1003.1-200x draft 6 rationale section C.2.6.4)
says that awk implementations "are encouraged to support signed
integer values at least as large as the size of the largest file
allowed on the implementation".  On recent Solaris and GNU/Linux
implementations, this would be 64-bit integers, as file sizes are 64
bits.  Switching awk from to "long" to "intmax_t" would help achieve
this.

Similarly, it might help to switch from "double" to "long double" if
the latter is available.



reply via email to

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