01.02.2014 Views

GNUPlot Manual

GNUPlot Manual

GNUPlot Manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

22 gnuplot 4.0 10 EXPRESSIONS<br />

10.2.2 Binary<br />

The following is a list of all the binary operators and their usages:<br />

Binary Operators<br />

Symbol Example Explanation<br />

** a**b exponentiation<br />

* a*b multiplication<br />

/ a/b division<br />

% a%b * modulo<br />

+ a+b addition<br />

- a-b subtraction<br />

== a==b equality<br />

!= a!=b inequality<br />

< a= a>=b greater than or equal to<br />

& a&b * bitwise AND<br />

^ a^b * bitwise exclusive OR<br />

| a|b * bitwise inclusive OR<br />

&& a&&b * logical AND<br />

|| a||b * logical OR<br />

(*) Starred explanations indicate that the operator requires integer arguments.<br />

Logical AND (&&) and OR (||) short-circuit the way they do in C. That is, the second && operand is<br />

not evaluated if the first is false; the second || operand is not evaluated if the first is true.<br />

10.2.3 Ternary<br />

There is a single ternary operator:<br />

Ternary Operator<br />

Symbol Example Explanation<br />

?: a?b:c ternary operation<br />

The ternary operator behaves as it does in C. The first argument (a), which must be an integer, is<br />

evaluated. If it is true (non-zero), the second argument (b) is evaluated and returned; otherwise the<br />

third argument (c) is evaluated and returned.<br />

The ternary operator is very useful both in constructing piecewise functions and in plotting points only<br />

when certain conditions are met.<br />

Examples:<br />

Plot a function that is to equal sin(x) for 0

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!