If one of the input numbers is I<unknown> then the result of the operation will be
I<unknown> too.
+B<MINNAN, MAXNAN>
+
+NAN-safe version of MIN and MAX. If one of the input numbers is I<unknown>
+then the result of the operation will be the other one. If both are
+I<unknown>, then the result of the operation is I<unknown>.
+
B<LIMIT>
Pops two elements from the stack and uses them to define a range.
add_op(OP_AVG, AVG)
add_op(OP_ABS, ABS)
add_op(OP_ADDNAN, ADDNAN)
+ add_op(OP_MINNAN, MINNAN)
+ add_op(OP_MAXNAN, MAXNAN)
#undef add_op
}
(*str)[offset] = '\0';
match_op(OP_AVG, AVG)
match_op(OP_ABS, ABS)
match_op(OP_ADDNAN, ADDNAN)
+ match_op(OP_MINNAN, MINNAN)
+ match_op(OP_MAXNAN, MAXNAN)
match_op(OP_MEDIAN, MEDIAN)
+
#undef match_op
else if ((sscanf(expr, DEF_NAM_FMT "%n", vname, &pos) == 1)
&& ((rpnp[steps].ptr = (*lookup) (key_hash, vname)) !=
rpnstack->s[stptr - 1] = rpnstack->s[stptr];
stptr--;
break;
+ case OP_MINNAN:
+ stackunderflow(1);
+ if (isnan(rpnstack->s[stptr - 1]))
+ rpnstack->s[stptr - 1] = rpnstack->s[stptr];
+ else if (isnan(rpnstack->s[stptr]));
+ else if (rpnstack->s[stptr - 1] > rpnstack->s[stptr])
+ rpnstack->s[stptr - 1] = rpnstack->s[stptr];
+ stptr--;
+ break;
case OP_MAX:
stackunderflow(1);
if (isnan(rpnstack->s[stptr - 1]));
rpnstack->s[stptr - 1] = rpnstack->s[stptr];
stptr--;
break;
+ case OP_MAXNAN:
+ stackunderflow(1);
+ if (isnan(rpnstack->s[stptr - 1]))
+ rpnstack->s[stptr - 1] = rpnstack->s[stptr];
+ else if (isnan(rpnstack->s[stptr]));
+ else if (rpnstack->s[stptr - 1] < rpnstack->s[stptr])
+ rpnstack->s[stptr - 1] = rpnstack->s[stptr];
+ stptr--;
+ break;
case OP_LIMIT:
stackunderflow(2);
if (isnan(rpnstack->s[stptr - 2]));
OP_ATAN, OP_SQRT, OP_SORT, OP_REV, OP_TREND, OP_TRENDNAN,
OP_ATAN2, OP_RAD2DEG, OP_DEG2RAD,
OP_PREDICT,OP_PREDICTSIGMA,
- OP_AVG, OP_ABS, OP_ADDNAN, OP_MEDIAN
-};
+ OP_AVG, OP_ABS, OP_ADDNAN,
+ OP_MINNAN, OP_MAXNAN,
+ OP_MEDIAN
+ };
typedef struct rpnp_t {
enum op_en op;