+2004-12-13 Miguel de Icaza <miguel@ximian.com>
+
+ * dis-cil.c, dump.c: Encode special constant +Inf, -Inf and NaN
+ using hex constants instead of letting libc print the values.
+
2004-12-11 Martin Baulig <martin@ximian.com>
* get.c (get_typespec): Added `gboolean is_def' argument; removed
#include <config.h>
#include <glib.h>
#include <stdio.h>
+#include <math.h>
#ifdef HAVE_WCHAR_H
#include <wchar.h>
#endif
case MonoInlineR: {
double r;
+ int inf;
readr8 (ptr, &r);
- fprintf (output, "%g", r);
+ inf = isinf (r);
+ if (inf == -1)
+ fprintf (output, "(00 00 00 00 00 00 f0 ff)"); /* negative infinity */
+ else if (inf == 1)
+ fprintf (output, "(00 00 00 00 00 00 f0 7f)"); /* positive infinity */
+ else if (isnan (r))
+ fprintf (output, "(00 00 00 00 00 00 f8 ff)"); /* NaN */
+ else
+ fprintf (output, "%g", r);
ptr += 8;
break;
}
case MonoShortInlineR: {
float f;
+ int inf;
+
readr4 (ptr, &f);
- fprintf (output, "%g", (double) f);
+ inf = isinf (f);
+ if (inf == -1)
+ fprintf (output, "(00 00 80 ff)"); /* negative infinity */
+ else if (inf == 1)
+ fprintf (output, "(00 00 80 7f)"); /* positive infinity */
+ else if (isnan (f))
+ fprintf (output, "(00 00 c0 ff)"); /* NaN */
+ else
+ fprintf (output, "%g", (double) f);
ptr += 4;
break;
}
#include <stdio.h>
#include <string.h>
#include <glib.h>
+#include <math.h>
#include "meta.h"
#include "util.h"
#include "dump.h"
break;
case MONO_TYPE_R4: {
float val;
+ int inf;
readr4 (p, &val);
- g_string_sprintfa (res, "%g", val);
+ inf = isinf (val);
+ if (inf == -1)
+ g_string_sprintfa (res, "(00 00 80 ff)"); /* negative infinity */
+ else if (inf == 1)
+ g_string_sprintfa (res, "(00 00 80 7f)"); /* positive infinity */
+ else if (isnan (val))
+ g_string_sprintfa (res, "(00 00 c0 ff)"); /* NaN */
+ else
+ g_string_sprintfa (res, "%g", val);
p += 4;
break;
}
case MONO_TYPE_R8: {
double val;
+ int inf;
+
readr8 (p, &val);
- g_string_sprintfa (res, "%g", val);
+ inf = isinf (val);
+ if (inf == -1)
+ g_string_sprintfa (res, "(00 00 00 00 00 00 f0 ff)"); /* negative infinity */
+ else if (inf == 1)
+ g_string_sprintfa (res, "(00 00 00 00 00 00 f0 7f)"); /* positive infinity */
+ else if (isnan (val))
+ g_string_sprintfa (res, "(00 00 00 00 00 00 f8 ff)"); /* NaN */
+ else
+ g_string_sprintfa (res, "%g", val);
p += 8;
break;
}