summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cf3eec0)
raw | patch | inline | side by side (parent: cf3eec0)
author | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Fri, 7 Mar 2008 08:57:01 +0000 (08:57 +0000) | ||
committer | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Fri, 7 Mar 2008 08:57:01 +0000 (08:57 +0000) |
NaN + NaN => NaN
x + NaN => x
NaN + y => y
x + y => x + y
-- Timo Stripf tstripf gmx.de
git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@1303 a5681a0c-68f1-0310-ab6d-d61299d08faa
x + NaN => x
NaN + y => y
x + y => x + y
-- Timo Stripf tstripf gmx.de
git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@1303 a5681a0c-68f1-0310-ab6d-d61299d08faa
doc/rrdgraph_rpn.pod | patch | blob | history | |
src/rrd_rpncalc.c | patch | blob | history | |
src/rrd_rpncalc.h | patch | blob | history |
diff --git a/doc/rrdgraph_rpn.pod b/doc/rrdgraph_rpn.pod
index 3718349cdbba42e80e991fb461511675cf18b48c..aabd7383e43979ae6396d0fc210aa3c879a55563 100644 (file)
--- a/doc/rrdgraph_rpn.pod
+++ b/doc/rrdgraph_rpn.pod
Add, subtract, multiply, divide, modulo
+B<ADDNAN>
+
+NAN-safe addition. If one parameter is NAN/UNKNOWN it'll be treated as
+zero. If both parameters are NAN/UNKNOWN, NAN/UNKNOWN will be returned.
+
B<SIN, COS, LOG, EXP, SQRT>
Sine and cosine (input in radians), log and exp (natural logarithm),
diff --git a/src/rrd_rpncalc.c b/src/rrd_rpncalc.c
index ed086626d1d21923aae50e904ad8821ede5ee459..839643b0075101429fe4171b9297f0d3867d11d0 100644 (file)
--- a/src/rrd_rpncalc.c
+++ b/src/rrd_rpncalc.c
add_op(OP_DEG2RAD, DEG2RAD)
add_op(OP_AVG, AVG)
add_op(OP_ABS, ABS)
+ add_op(OP_ADDNAN, ADDNAN)
#undef add_op
}
(*str)[offset] = '\0';
match_op(OP_DEG2RAD, DEG2RAD)
match_op(OP_AVG, AVG)
match_op(OP_ABS, ABS)
+ match_op(OP_ADDNAN, ADDNAN)
#undef match_op
else if ((sscanf(expr, DEF_NAM_FMT "%n", vname, &pos) == 1)
&& ((rpnp[steps].ptr = (*lookup) (key_hash, vname)) !=
+ rpnstack->s[stptr];
stptr--;
break;
+ case OP_ADDNAN:
+ stackunderflow(1);
+ if (isnan(rpnstack->s[stptr - 1])) {
+ rpnstack->s[stptr - 1] = rpnstack->s[stptr];
+ } else if (isnan(rpnstack->s[stptr])) {
+ //rpnstack->s[stptr - 1] = rpnstack->s[stptr - 1];
+ } else {
+ rpnstack->s[stptr - 1] = rpnstack->s[stptr - 1]
+ + rpnstack->s[stptr];
+ }
+
+ stptr--;
+ break;
case OP_SUB:
stackunderflow(1);
rpnstack->s[stptr - 1] = rpnstack->s[stptr - 1]
diff --git a/src/rrd_rpncalc.h b/src/rrd_rpncalc.h
index b178f05fa2783cf109007918f5a275b0f946c996..3e4da4c796a5855fa42a08ef66348604a19a7c58 100644 (file)
--- a/src/rrd_rpncalc.h
+++ b/src/rrd_rpncalc.h
OP_UN, OP_END, OP_LTIME, OP_NE, OP_ISINF, OP_PREV_OTHER, OP_COUNT,
OP_ATAN, OP_SQRT, OP_SORT, OP_REV, OP_TREND, OP_TRENDNAN,
OP_ATAN2, OP_RAD2DEG, OP_DEG2RAD,
- OP_AVG, OP_ABS
+ OP_AVG, OP_ABS, OP_ADDNAN
};
typedef struct rpnp_t {