-This tutorial should help you get to grips with rrdtool RPN expressions
-as seen in CDEF arguments of rrdtool graph.
+This tutorial should help you get to grips with RRDtool RPN expressions
+as seen in CDEF arguments of RRDtool graph.
("Z") branch. Read the RPN expression "X,Y,Z,IF" from left to
right like so: "if X then Y else Z".
("Z") branch. Read the RPN expression "X,Y,Z,IF" from left to
right like so: "if X then Y else Z".
-For example, consider "1,10,100,IF". It looks bizzare to me.
+For example, consider "1,10,100,IF". It looks bizarre to me.
But when I read "if 1 then 10 else 100" it's crystal clear: 1 is true
so the answer is 10. Note that only zero is false; all other values
are true. "2,20,200,IF" ("if 2 then 20 else 200") evaluates to 20.
But when I read "if 1 then 10 else 100" it's crystal clear: 1 is true
so the answer is 10. Note that only zero is false; all other values
are true. "2,20,200,IF" ("if 2 then 20 else 200") evaluates to 20.
2) 1,5,+ eval is 1,5,+ = 6 result is 6
3) 6
2) 1,5,+ eval is 1,5,+ = 6 result is 6
3) 6
with multiple logic operators:
1) 20,10,GT,10,20,IF eval is 20,10,GT = 1 result is 1,10,20,IF
with multiple logic operators:
1) 20,10,GT,10,20,IF eval is 20,10,GT = 1 result is 1,10,20,IF
Traditional mathematic expressions are evaluated by
doing multiplication and division first, then addition and
Traditional mathematic expressions are evaluated by
doing multiplication and division first, then addition and
addition before multiplication (etc). RPN does not require
parentheses because the ordering of objects on the stack
can force the evaluation of addition before multiplication.
addition before multiplication (etc). RPN does not require
parentheses because the ordering of objects on the stack
can force the evaluation of addition before multiplication.