Index: src/rrd_rpncalc.c
===================================================================
--- src/rrd_rpncalc.c	(revision 1301)
+++ src/rrd_rpncalc.c	(working copy)
@@ -178,6 +178,7 @@
             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';
@@ -374,6 +375,7 @@
             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)) !=
@@ -543,6 +545,19 @@
                 + 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]
Index: src/rrd_rpncalc.h
===================================================================
--- src/rrd_rpncalc.h	(revision 1301)
+++ src/rrd_rpncalc.h	(working copy)
@@ -18,7 +18,7 @@
     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 {
Index: doc/rrdgraph_rpn.pod
===================================================================
--- doc/rrdgraph_rpn.pod	(revision 1301)
+++ doc/rrdgraph_rpn.pod	(working copy)
@@ -99,6 +99,11 @@
 
 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),
