Arithmetic Operations; Relational Operations; Logical Operations - Juniper JUNOSE SOFTWARE FOR E SERIES 11.3.X - SYSTEM BASICS CONFIGURATION GUIDE 2010-10-04 Configuration Manual

Software for e series broadband services routers system basics configuration guide
Hide thumbs Also See for JUNOSE SOFTWARE FOR E SERIES 11.3.X - SYSTEM BASICS CONFIGURATION GUIDE 2010-10-04:
Table of Contents

Advertisement

JunosE 11.3.x System Basics Configuration Guide

Arithmetic Operations

Example
Example
Example
470
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.
<# 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.
<# 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.
<# 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.

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the JUNOSE SOFTWARE FOR E SERIES 11.3.X - SYSTEM BASICS CONFIGURATION GUIDE 2010-10-04 and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Junose 11.3

Table of Contents