summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ee18199)
raw | patch | inline | side by side (parent: ee18199)
author | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Thu, 11 May 2006 11:11:04 +0000 (11:11 +0000) | ||
committer | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Thu, 11 May 2006 11:11:04 +0000 (11:11 +0000) |
program/src/rrd_nan_inf.c | patch | blob | history |
index 22886c4b9085d5fe5a0b3fa9d3392f87a7e40e97..2a5ac1455cd3c50b57fca647b5e59fcf99a477bc 100644 (file)
#include "rrd_nan_inf.h"
-#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
+int done_nan = 0;
+int done_inf = 0;
+
+double dnan;
+double dinf;
+#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
#include <math.h>
-double set_to_DNAN(void) { return (double)fmod(0.0,0.0); }
-double set_to_DINF(void) { return (double)fabs((double)log(0.0)); }
+#define NAN_FUNC (double)fmod(0.0,0.0)
+#define INF_FUNC (double)fabs((double)log(0.0))
#else
-double set_to_DNAN(void) { return (double)(0.0/0.0); }
-double set_to_DINF(void) { return (double)(1.0/0.0); }
+#define NAN_FUNC (double)(0.0/0.0)
+#define INF_FUNC (double)(1.0/0.0)
#endif
+
+double set_to_DNAN(void)
+{
+ if ( !done_nan ) { dnan = NAN_FUNC; done_nan = 1; }
+ return dnan;
+}
+
+double set_to_DINF(void)
+{
+ if ( !done_inf ) { dinf = INF_FUNC; done_inf = 1; }
+ return dinf;
+}