Arithmetic Operators
Here are the common arithmetic operators:
-
+ Used to add numbers. It can also be used to perform string concatenation.
- -
Used to perform subtraction. It can also be used to perform string subtraction. For example, '
cat, dog, mouse' - ', dog' results in the string 'cat, mouse‘.-
* Used to multiply numbers.
-
/ Used to divide numbers. Note that NASL will return a 0 if you try to divide by zero.
-
% Used to perform a modulo operation. For example,
10%3computes to 1.-
** Used to perform exponentiation. For example,
2**3computes to 8.-
++ Used to increment a variable’s value by 1. When a variable is prefixed by this operator (example:
++c), its value is incremented before it is evaluated. When a variable is post-fixed by this operator (example:c++), its value is incremented after it is evaluated.- —
Used to decrement a variable’s value by 1. When a variable is prefixed by this operator (example:
--c), its value is decremented before it is evaluated. When a variable is post-fixed by this operator (example:c--), its value is decremented after it is evaluated.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access