Update release notes with discussion of new floating-point features.

This commit is contained in:
Stephen Heumann 2021-03-09 18:01:30 -06:00
parent 4381b97f86
commit db7a0a995d

View File

@ -125,10 +125,10 @@ p. 240
The discussion of escape sequences states that hexadecimal numeric escape sequences can contain from one to three digits. This was true until ORCA/C 2.1, when the compiler was changed to respect the ANSI C standard. The compiler will now scan a hexadecimal numeric escape sequence until no more hexadecimal characters are found. The result is then anded with 0x00FF to yield a single character. (ORCA/C 2.1 would also scan an octal escape sequence until no more octal characters were found, but this has been changed back to limit octal escape sequences to at most three octal digits, as required by the C standards.)
The discussion concerning floating-point constants is misleading. While constants are indeed handled as extended values in the executable program, the compiler itself uses double values for the constants internally, so you need to adhere to the valid exponent range for double values, and you should expect to see accuracy in constants that is in line with double values.
p. 241
The 'f', 'F', 'l', or 'L' suffixes on floating-point constants do now affect the semantic type of those constants, although they do not change the constant's precision or range (which are always those of the SANE extended format).
ORCA/C now supports // comments. See "// Comments," below.
p. 247
@ -209,7 +209,9 @@ If integer overflow occurs during signed integer multiplication, the resulting v
p. 321
The unary conversion rules have been modified to convert values of type char or unsigned char to int (rather than unsigned int), as required by the C standards.
The unary conversion rules have been modified to convert values of type char or unsigned char to int (rather than unsigned int), as required by the C standards. Also, they do not change the semantic type of float or double values.
In the binary conversions, if either operand has a floating-point type, the semantic type is the largest floating-point type of either operand. However, floating-point operations are always evaluated with the range and precision of the SANE extended format.
p. 337
@ -236,6 +238,8 @@ p. 342
Several new standard library functions from C99 and C11 are now provided. See "Library Updates," below.
All the functions in <math.h> that are specified as having argument or return types of extended actually use the type double. However, the values passed to and returned from them still have the range and precision of the extended type.
p. 343
The documentation states that assert() uses exit(-1) to exit a program. Actually, it uses abort().
@ -441,6 +445,17 @@ Note that MPW IIGS ORCA/C also supports multi-character constants and #pragma ig
(Mike Westerfield, Kelvin Sherlock, Stephen Heumann)
Evaluation of Floating-Point Expressions and Constants
------------------------------------------------------
There have been some changes to the way ORCA/C evaluates floating-point expressions and constants. ORCA/C has always used the SANE extended format (which is the format of long double) to evaluate floating-point expressions at run time, even if their semantic type in the standard C language was float or double. However, it previously used the double format to evaluate constant expressions that could be computed at compile time. Now, it uses the extended format for those computations too, producing consistent results for a computation regardless of whether it is done at compile time or run time.
ORCA/C also historically used the double format internally to hold the values of all floating-point constants, even those with an 'L' suffix indicating they were of type long double. It now uses the extended format for all floating-point constants. This allows long double constants to be represented with the full range and precision that they should have. It also provides extra range and precision for constants of type float or double, beyond what would be provided if they were simply represented using their semantic type.
Using the extended format provides greater precision and range than the float or double formats, and can lead to more accurate results. However, using it for expressions or constants with shorter semantic types can cause behavior that may be surprising. For example, a variable of type double that has had a constant of type double assigned to it may not compare equal to that same constant. This behavior is allowed under the C standards (the new behavior is designed to be consistent with a FLT_EVAL_METHOD value of 2, as defined in the C99 and later standards), but it is different from that of some C compilers on other systems.
If you want to get a value strictly in a certain type with no extra range or precision, you can store it in a variable of that type or explicitly cast it to that type. (In older versions of ORCA/C, floating-point casts did not remove extra range or precision, but now they do, as required by the C standards.)
Additions to #pragma ignore
---------------------------
Several additional #pragma ignore bits are now supported.
@ -647,6 +662,20 @@ fegetround() gets the current rounding direction. fesetround() sets the roundin
Except for fetestexcept() and fegetround(), these calls return 0 if they successfully carried out the operation, or non-zero otherwise. Under ORCA/C, they always succeed if given valid arguments. Under ORCA/C, these functions all correspond to operations on the SANE environment; see the Apple Numerics Manual for details on its behavior. To ensure that these functions interact properly with floating-point operations in the program, #pragma STDC FENV_ACCESS ON should be in effect when they are called; see "New Language Features," above.
10. (C99) Several new function-like macros for classification of floating-point numbers have been added:
#include <math.h>
int fpclassify(real-floating x);
int isfinite(real-floating x);
int isinf(real-floating x);
int isnan(real-floating x);
int isnormal(real-floating x);
int signbit(real-floating x);
These macros accept an argument of any real floating type, i.e. float, double, or long double. They behave as if they convert the argument strictly to its semantic type before classifying it, removing any extra range and precision.
fpclassify() returns one of the macro values FP_INFINITE, FP_NAN, FP_NORMAL, FP_SUBNORMAL, or FP_ZERO, indicating the classification of its argument. isfinite() returns a non-zero value if its argument is normal, subnormal, or zero (not infinite or NAN). isinf(), isnan(), and isnormal() return a non-zero value if their arguments are infinite, NAN, or normal, respectively. signbit() returns zero if the argument has a positive sign, and non-zero if it has a negative sign (this applies to all floating-point values, even zeros and NANs).
-- Compiler changes introduced in C 2.1.0 -----------------------------------
The Default .h File
@ -998,7 +1027,7 @@ int foo(int[42]);
85. Errors displayed for source lines indented with tabs would typically appear to be at the wrong position (depending on how the console in use displays tabs).
86. The LDBL_* values in <float.h> were all wrong. They specified values for the double format, not the SANE extended format actually used for long double. Most of them have now been corrected; however, LDBL_MAX and LDBL_MIN are still incorrect, because ORCA/C internally represents floating-point constants in the double format, which is not capable of holding the proper values for them.
86. The LDBL_* values in <float.h> were all wrong. They specified values for the double format, not the SANE extended format actually used for long double. As of ORCA/C 2.2.0 B5, all of them now have the correct values.
87. perror() should write only a single new-line. Also, it should not write the prefix string, colon and space if the prefix string pointer is NULL or if it points to an empty string.
@ -1151,6 +1180,12 @@ int foo(int[42]);
(Kelvin Sherlock)
150. Constants and constant expressions of type long double (aka extended) were only represented and evaluated with the range and precision of double, often producing less accurate results and potentially giving infinities for numbers that should have been within the range of finite long double values. Now, they are evaluated in the long double format, with its full range and precision. In fact, all floating-point expressions are now evaluated in the long double format. See "Evaluation of Floating-Point Expressions and Constants," above.
151. An explicit cast to a floating-point type should produce a value that is exactly representable in that type's format, with no extra range or precision. Similarly, the value of an assignment expression should be exactly the value stored, with no more range or precision than that of the location it was stored to. ORCA/C was not reducing the range and precision of floating-point values in these cases, but now it does.
152. sizeof did not give the right values for certain expressions of floating-point and character types, including expressions cast to those types.
-- Bugs from C 2.1.0 that have been fixed -----------------------------------
1. In some situations, fread() reread the first 1K or so of the file.