=================================================================== RCS file: RCS/printcmd.c,v retrieving revision 1.1 diff -c3 -r1.1 printcmd.c *** /tmp/,RCSt1011248 Tue Jan 12 14:06:06 1988 --- printcmd.c Mon Sep 21 21:33:39 1987 *************** *** 174,179 VALUE_TYPE (val) = builtin_type_float; if (TYPE_LENGTH (VALUE_TYPE (val)) == sizeof (double)) VALUE_TYPE (val) = builtin_type_double; printf ("%g", value_as_double (val)); break; --- 174,185 ----- VALUE_TYPE (val) = builtin_type_float; if (TYPE_LENGTH (VALUE_TYPE (val)) == sizeof (double)) VALUE_TYPE (val) = builtin_type_double; + #ifdef PRINTF_BUG + if (is_nan(value_as_double (val))) + printf ("Nan"); + else + printf ("%g", value_as_double (val)); + #else printf ("%g", value_as_double (val)); #endif break; *************** *** 175,180 if (TYPE_LENGTH (VALUE_TYPE (val)) == sizeof (double)) VALUE_TYPE (val) = builtin_type_double; printf ("%g", value_as_double (val)); break; case 0: --- 181,187 ----- printf ("%g", value_as_double (val)); #else printf ("%g", value_as_double (val)); + #endif break; case 0: =================================================================== RCS file: RCS/valprint.c,v retrieving revision 1.1 diff -c3 -r1.1 valprint.c *** /tmp/,RCSt1011248 Tue Jan 12 14:06:09 1988 --- valprint.c Mon Sep 21 21:35:45 1987 *************** *** 21,26 #include #include "defs.h" #include "initialize.h" #include "symtab.h" #include "value.h" --- 21,27 ----- #include #include "defs.h" #include "initialize.h" + #include "param.h" #include "symtab.h" #include "value.h" *************** *** 249,255 break; case TYPE_CODE_FLT: ! fprintf (stream, "%g", unpack_double (type, valaddr)); break; case TYPE_CODE_VOID: --- 250,265 ----- break; case TYPE_CODE_FLT: ! { double d = unpack_double (type, valaddr); ! #ifdef PRINTF_BUG ! if (is_nan(d)) ! fprintf (stream, "Nan"); ! else ! fprintf (stream, "%g", d); ! #else ! fprintf (stream, "%g", d); ! #endif ! } break; case TYPE_CODE_VOID: *************** *** 559,563 float_type_table[sizeof (float)] = "float"; float_type_table[sizeof (double)] = "double"; } END_FILE --- 569,599 ----- float_type_table[sizeof (float)] = "float"; float_type_table[sizeof (double)] = "double"; } + + + #ifdef PRINTF_BUG + + struct ieee { /* IEEE floating format */ + unsigned int s:1; + unsigned int e:11; + unsigned int f1:20; + unsigned int f2; + }; + + #define ZERO_F(x) ((x.f1 == 0) && (x.f2 == 0)) /* zero fraction ? */ + #define ZERO_E(x) (x.e == 0) /* zero exponential ? */ + #define MAX_E(x) (x.e == 0x7ff) /* max exponential ? */ + #define MINUS_S(x) (x.s == 1) /* minus ? */ + + int + is_nan(arg) /* Not a Number ? */ + struct ieee arg; + { + if (MAX_E(arg) && !ZERO_F(arg)) + return (1); + else + return (0); + } + #endif END_FILE