Skip to main content

1.8) Simple Mathematical Operators


Let's assume that "x" and "y" are floating point numbers equal to 2.0 and 3.0 respectively. Using the following mathematical operators applied to "x" and "y":

Operator Description Example
+ Addition IDL> print, x + 7
IDL prints 5.00000
- Subtraction IDL> print, x - y
IDL prints -1.00000
* Multiplication IDL> print, x * y
IDL prints 6.00000
/ Division IDL> print, x / y
IDL prints 0.666667
++ Increment, (two plus signs) adds one to the operand IDL> x++
IDL> print, x
IDL prints 3.00000
-- Decrement, (two minus signs) subtracts one from the operand IDL> x--
IDL> print, x
IDL prints 1.00000
^ Exponential, (raise to the power of) IDL> print, x^y
IDL prints 8.00000
mod Modulo, gives the remainder of a division IDL> print, x mod y
IDL prints 2.00000