On 2023-01-20, Keith Thompson <
Keith.S.T...@gmail.com> wrote:
> Different implementations of awk might use different floating-point
> representations on different platforms. I don't think the
> characteristics of floating-point are defined by the language.
> (Is there even a formal language definition?)
In defining Awk, the POSIX spec defers a lot of details to C,
which seems like handwaving, but actually pins things down.
E.g. in the area of numeric constants:
The token NUMBER shall represent a numeric constant. Its form and
numeric value shall either be equivalent to the
decimal-floating-constant token as specified by the ISO C standard, or
it shall be a sequence of decimal digits and shall be evaluated as an
integer constant in decimal. In addition, implementations may accept
numeric constants with the form and numeric value equivalent to the
hexadecimal-constant and hexadecimal-floating-constant tokens as
specified by the ISO C standard.
If the value is too large or too small to be representable (see
Concepts Derived from the ISO C Standard), the behavior is undefined.
This "Concepts Derived from the ISO C Standard" section is a general
one, outside of the Awk chapter.
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap01.html#tag_17_01_02
It's a large section, whose earliest paragraphs are relevant to Awk
numerics.
1.1.2 Concepts Derived from the ISO C Standard
Some of the standard utilities perform complex data manipulation using
their own procedure and arithmetic languages, as defined in their
EXTENDED DESCRIPTION or OPERANDS sections. Unless otherwise noted, the
arithmetic and semantic concepts (precision, type conversion, control
flow, and so on) shall be equivalent to those defined in the ISO C
standard, as described in the following sections. Note that there is no
requirement that the standard utilities be implemented in any particular
programming language.
Arithmetic Precision and Operations
Integer variables and constants, including the values of operands and
option-arguments, used by the standard utilities listed in this volume
of POSIX.1-2017 shall be implemented as equivalent to the ISO C standard
signed long data type; floating point shall be implemented as equivalent
to the ISO C standard double type. Conversions between types shall be as
described in the ISO C standard. All variables shall be initialized to
zero if they are not otherwise assigned by the input to the application.
[ ... ]
--
TXR Programming Language:
http://nongnu.org/txr
Cygnal: Cygwin Native Application Library:
http://kylheku.com/cygnal
Mastodon: @
Kazi...@mstdn.ca