Arithmetic Operations; Relational Operations; Logical Operations - Juniper SYSTEM BASICS - CONFIGURATION GUIDE V 11.1.X Configuration Manual

System basics configuration guide software for e series broadband services routers
Table of Contents

Advertisement

JUNOSe 11.1.x System Basics Configuration Guide
<# decimal:= 4.7 #>
<# round(decimal) #>The result is decimal is now 5
The truncate operator truncates noninteger numbers to the value left of the decimal
point:
<# decimal:= 4.7 #>
<# truncate(decimal) #>The result is decimal is now 4

Arithmetic Operations

The arithmetic operations are multiply (*), divide (/), modulo (%), add (+), and
subtract (-). Multiply, divide, and modulo are equal in precedence, but each has a
higher precedence relative to add and subtract. Add and subtract are equal in
precedence.
Example
<# 4 % 3 + 12 - 6 #>The result is 7
When a local variable with a string value is used with arithmetic operators, the value
is temporarily converted to an integer equal to the length in characters of the string
value. You can use the env.atoi commands to avoid this situation.

Relational Operations

The relational operations compare the value of the expression to the left of the
operator with the value of the expression to the right. The result of the comparison
is 1 if the comparison is true and 0 if the comparison is false.
If the expressions on both sides of the operator are strings, they are compared
alphabetically. If only one expression is a string, the numeric value is used for
comparison. Arithmetic operators have a higher precedence.
Example
<# i := 9; i++ < 10 #>The result is 1
<# i := 9; ++i < 10 #>The result is 0

Logical Operations

You can use the logical operators AND (&&), OR (||), and NOT (!) to evaluate
expressions. The result of the operation is a 1 if the operation is true and 0 if the
operation is false.
For the logical AND, the result of the operation is true (1) if the values of the
expressions to the left and right of the operator are both nonzero. The result of the
operation is false (0) if either value is zero. The evaluation halts when an expression
is evaluated as zero.
For the logical OR, the result of the operation is true (1) if the values of the expression
on either the left or right of the operator is nonzero. The result of the operation is
false (0) if both values are zero. The evaluation halts when an expression is evaluated
as nonzero.
The NOT operator must precede the operand. The operation inverts the value of the
operand; that is, a nonzero expression becomes 0, and a zero expression becomes
484
Writing Macros

Advertisement

Table of Contents
loading

This manual is also suitable for:

Junose 11.1

Table of Contents