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),
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]
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 {