Adriaan van Os wrote:
lanceboyle@qwest.net wrote:
What is the relationship between GPC and IEEE 754 floating point?
Platform dependent, see http://www.gnu-pascal.de/crystal/gpc/en/thread10316.html.
THINK and CW (both Mac dialects) allowed e.g.
a := Inf; a := -Inf; a := NaN;
but these are rejected by GPC as undeclared identifiers.
<snip>
The gcc compiler does have Inf and NaN, see e.g. the compiler sources gcc-42/gcc-4.2-20060408/gcc/testsuite/gcc.c-torture/execute/ieee, builtin-nan-1.c, inf-1.c and inf-2.c
double n1 = __builtin_nan("0x1"); double n2 = __builtin_nan("0X1");
float fi = __builtin_inff(); double di = __builtin_inf(); long double li = __builtin_infl();
float fh = __builtin_huge_valf(); double dh = __builtin_huge_val(); long double lh = __builtin_huge_vall();
I believe you can't use gcc builtins directly from gpc, except by linking in a few lines of C.
AFAICS those builtins appeared in gcc-3.3.x (I could not find __builtin_nan in earlier backends). I do not know what they will do on non-IEEE hardware (fortunately such hardware is getting rare). With some effort we can add them to GPC as predefined routines (Inf probably as a constant).