Skip to main content

Operator Reference

+

+ produces the sum of two numbers or waves.

It can also be used to concatenate strings.

See Operators for a list of all operators in order of precedence.

-

- produces the difference of two numbers or waves.

See Operators for a list of all operators in order of precedence.

*

* produces the product of two numbers or waves.

See Operators for a list of all operators in order of precedence.

/

/ produces the quotient of two numbers or waves.

See Operators for a list of all operators in order of precedence.

^

^ Raises a number or wave to a power.

For example, wave1 = wave2^3 sets wave1 equal to the cube of wave2. In an expression a^b, if result is used in a real expression, a must not be negative if b is not an integer. If result is used in a complex expression, a and b may be any combination of negative, fractional, and complex numbers.

See Operators for a list of all operators in order of precedence.

!

! is the logical negation operator.

The number zero is considered false and any nonzero number is considered true. ! changes 0 (false) to 1 (true) and any nonzero number (true) to 0 (false).

See Operators for a list of all operators in order of precedence.

&&

&& is the logical AND operator.

Evaluates the truth or falseness of a pair of expressions; returns true only if both are true.

See Operators for a list of all operators in order of precedence.

||

|| is the logical OR operator.

Evaluates the truth or falseness of a pair of expressions; returns true if either one is true.

See Operators for a list of all operators in order of precedence.

&

& is the bitwise AND operator.

Produces the bitwise AND of its two operands after converting them to integers. See also Using Bitwise Operators.

See Operators for a list of all operators in order of precedence.

|

| (vertical bar) is the bitwise OR operator.

Produces the bitwise OR of its two operands after converting them to integers. See also Using Bitwise Operators.

See Operators for a list of all operators in order of precedence.

%^

%^ is the bitwise exclusive OR operator.

Produces the bitwise exclusive OR of its two operands after converting them to integers. See also Using Bitwise Operators.

See Operators for a list of all operators in order of precedence.

~

~ is the bitwise COMPLEMENT operator. It produces the bitwise COMPLEMENT of its single operand after converting it to integer. See also Using Bitwise Operators.

See Operators for a list of all operators in order of precedence.

? :

? : is the conditional operator, which is a shorthand form of an if-else-endif statement. It is of the form:

<expression> ? <TRUE> : <FALSE>  

When expression is nonzero, it evaluates the TRUE part, otherwise it evaluates the FALSE part. The ":" character in the conditional operator must always be separated with spaces from the two adjacent operands. The operands must be numeric; for strings, you must use the SelectString function.

See Operators for a list of all operators in order of precedence.

Examples

Replace zero values with blanks:

Wave w = wave0
w = w[p]==0 ? NaN : w[p]

See Also

SelectNumber, SelectString, If-Else-Endif Statements

==

== takes a left hand operand and a right hand operand, both of which are scalar numbers. It returns true (1) if the operands are equal or false (0) if they are not.

Comparison operators do not work with NaN parameters. Use numtype to test if a value is NaN.

Comparison operators can be useful in synthesizing waves. See Example: Comparison Operators and Wave Synthesis.

See Operators for a list of all operators in order of precedence.

!=

!= takes a left hand operand and a right hand operand, both of which are scalar numbers. It returns true (1) if the operands are not equal or false (0) if they are equal.

Comparison operators do not work with NaN parameters. Use numtype to test if a value is NaN.

Comparison operators can be useful in synthesizing waves. See Example: Comparison Operators and Wave Synthesis.

See Operators for a list of all operators in order of precedence.

>=

>= takes a left hand operand and a right hand operand, both of which are scalar numbers. It returns true (1) if the left operand is greater than or equal to the right operand or false (0) otherwise.

Comparison operators can be useful in synthesizing waves. See Example: Comparison Operators and Wave Synthesis.

See Operators for a list of all operators in order of precedence.

>

> takes a left hand operand and a right hand operand, both of which are scalar numbers. It returns true (1) if the left operand is greater than the right operand or false (0) otherwise.

Comparison operators can be useful in synthesizing waves. See Example: Comparison Operators and Wave Synthesis.

See Operators for a list of all operators in order of precedence.

<=

<= takes a left hand operand and a right hand operand, both of which are scalar numbers. It returns true (1) if the left operand is less than or equal to the right operand or false (0) otherwise.

The comparison operators can be useful in synthesizing waves. See Example: Comparison Operators and Wave Synthesis.

See Operators for a list of all operators in order of precedence.

<

< takes a left hand operand and a right hand operand, both of which are scalar numbers. It returns true (1) if the left operand is less than the right operand or false (0) otherwise.

Comparison operators can be useful in synthesizing waves. See Example: Comparison Operators and Wave Synthesis.

See Operators for a list of all operators in order of precedence.

See Also

Operators, Assignment Operators, Waveform Arithmetic and Assignment, Example: Comparison Operators and Wave Synthesis

++

++ increments its operand. It works on local variables in user-defined functions only and requires Igor Pro 7 or later.

++ may appear before its operand in which case it is called a pre-increment operator and returns the value of the operand after it is incremented.

++ may also appear after its operand in which case it is called a post-increment operator and returns the value of the operand before it is incremented.

See Operators for a list of all operators in order of precedence.

Examples

Function Test()
Variable operand
operand = 1
Variable result = ++operand // result = 2, operand = 2
operand = 1
Variable result = operand++ // result = 1, operand = 2
End

--

-- decrements its operand. It works on local variables in user-defined functions only and requires Igor Pro 7 or later.

-- may appear before its operand in which case it is called a pre-decrement operator and returns the value of the operand after it is decremented.

-- may also appear after its operand in which case it is called a post-decrement operator and returns the value of the operand before it is decremented.

See Operators for a list of all operators in order of precedence.

Examples

Function Test()
Variable operand
operand = 1
Variable result = --operand // result = 0, operand = 0
operand = 1
Variable result = operand-- // result = 1, operand = 0
End

<<

<< is the bitwise left shift operator. It returns the value of its lefthand operand shifted left by the number of bits specified by its righthand operand. It requires Igor Pro 7 or later. << converts its lefthand operand to an integer by truncation before doing the shifting.

See Operators for a list of all operators in order of precedence.

Examples

Function Test()
Variable val = 2
Variable result = val << 1 // result = 4
End

>>

>> is the bitwise right shift operator. It returns the value of its lefthand operand shifted right by the number of bits specified by its righthand operand. It requires Igor Pro 7 or later. >> converts its lefthand operand to an integer by truncation before doing the shifting.

See Operators for a list of all operators in order of precedence.

Examples

Function Test()
Variable val = 2
Variable result = val >> 1 // result = 1
End