[rrd-users] Re: Math functions in RRD-graph

Alex van den Bogaerdt alex at slot.hollandcasino.nl
Tue Feb 5 00:29:53 MET 2002

Edwin Nadorp wrote:

> I calculate the diverence by a - b = c
> But when b is greater then a the result is an negative number. I dont
> like that.
> So my question:
> How can i calculate the line by the folowing function : abs(a - b) =
> c ??

You want to have
     c == a - b   for a>b
and  c == b - a   in other cases


Alternatively, you can do:
     c == a - b; if (c<0) c=c*-1 else c=c*1;

this does: calculate a-b; duplicate; use the duplicate to check
against being less than zero; multiply with -1 if so, with 1 if not.

These examples do not check for being the INF, -INF or UNKN value.

 / alex at slot.hollandcasino.nl                  alex at ergens.op.het.net \
| work                                                         private |
| My employer is capable of speaking therefore I speak only for myself |
| Technical questions sent directly to me will be nuked. Use the list. | 
| http://faq.mrtg.org/                                                 |
| http://rrdtool.eu.org  --> tutorial                                  |

Unsubscribe mailto:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-users-request at list.ee.ethz.ch?subject=help
Archive     http://www.ee.ethz.ch/~slist/rrd-users
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi

More information about the rrd-users mailing list