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 1. For
the logical NOT, the result of the operation is true (1) if it evaluates to zero, or false if it
evaluates to nonzero.
Example
<# i := 6; i >= 3 && i <= 10 #>The result is 1
<# i := 1; i >= 3 && i <= 10 #>The result is 0
<# i := 6; i >= 3 || i <= 10 #>The result is 1
<# i := 1; i >= 3 && i <= 10 #>The result is 0
<# i := 5; !i #> The result is 0
<# i := 5; j := 0; !i && !j #>The result is 0
<# i := 5; j := 0; !i || !j #>The result is 1
Relational operators have a higher precedence than logical AND and OR. The NOT
operator is equal in precedence to the increment and decrement operators.
Copyright © 2010, Juniper Networks, Inc.
470
JunosE 11.3.x System Basics Configuration Guide
Summary of Contents for JUNOSE 11.3
Page 6: ...Copyright 2010 Juniper Networks Inc vi...
Page 8: ...Copyright 2010 Juniper Networks Inc viii JunosE 11 3 x System Basics Configuration Guide...
Page 24: ...Copyright 2010 Juniper Networks Inc xxiv JunosE 11 3 x System Basics Configuration Guide...
Page 32: ...Copyright 2010 Juniper Networks Inc 2 JunosE 11 3 x System Basics Configuration Guide...
Page 146: ...Copyright 2010 Juniper Networks Inc 116 JunosE 11 3 x System Basics Configuration Guide...
Page 166: ...Copyright 2010 Juniper Networks Inc 136 JunosE 11 3 x System Basics Configuration Guide...
Page 432: ...Copyright 2010 Juniper Networks Inc 402 JunosE 11 3 x System Basics Configuration Guide...
Page 488: ...Copyright 2010 Juniper Networks Inc 458 JunosE 11 3 x System Basics Configuration Guide...
Page 524: ...Copyright 2010 Juniper Networks Inc 494 JunosE 11 3 x System Basics Configuration Guide...
Page 554: ...Copyright 2010 Juniper Networks Inc 524 JunosE 11 3 x System Basics Configuration Guide...
Page 566: ...Copyright 2010 Juniper Networks Inc 536 JunosE 11 3 x System Basics Configuration Guide...
Page 588: ...Copyright 2010 Juniper Networks Inc 558 JunosE 11 3 x System Basics Configuration Guide...
Page 613: ...PART 3 Index Index on page 585 583 Copyright 2010 Juniper Networks Inc...
Page 614: ...Copyright 2010 Juniper Networks Inc 584 JunosE 11 3 x System Basics Configuration Guide...
Page 632: ...Copyright 2010 Juniper Networks Inc 602 JunosE 11 3 x System Basics Configuration Guide...