An operator is a series of characters that allows an operation to be performed between one or more data and produces a result. It describes the use and utility of the different types of operators found in a programming language. The objective of the operators is to be able to realize operations using two or more stored data and the result is decisive for specifying the flow of information.

# 1 Arithmetic Operators

Arithmetic operators can do mathematical operations by combining different types of information. They use two or more operands in the form of constants or variables and return a single value as a result.

Like the mathematical world, in any programming language, they follow the same rules of origin found in the world of mathematics. It should be noted that the operations of multiplication and division will always be solved before the operations of addition and subtraction.

You can also alter the order of the origin by using parentheses. So, it allows to reverse the order to specify that the addition or subtraction will be executed before the multiplication or division.

Basic arithmetic operators include:

• ( + ) Addition
• ( - ) Subtraction
• ( * ) Multiplication
• ( / ) Division
• ( % ) Modulus
Copy
<xsql-script>
<body>
<set name='m_value_a'>5</set>
<set name='m_value_b'>2</set>
<set name='m_value_c'>12</set>
<set name='m_value_d'>4</set>
<set name='m_value_e'>3</set>

<m_value_a /><m_value_c />
</set>

<set name='m_value2'>  <!-- Subtraction -->
<sub>
<m_value_c /><m_value_d />
</sub>
</set>

<println>Subtraction result: [<m_value2/>]</println>

<set name='m_value3'>  <!-- Multiplication -->
<mul>
<m_value_a /><m_value_e />
</mul>
</set>

<println>Multiplication result: [<m_value3/>]</println>

<set name='m_value4'>  <!-- Division -->
<div>
<m_value_c /><m_value_b />
</div>
</set>

<println>Division result: [<m_value4/>]</println>

<set name='m_value5'>  <!-- Modulus -->
<mod>
<m_value_d /><m_value_e />
</mod>
</set>

<println>Modulus result: [<m_value5/>]</println>
</body>
</xsql-script>
Copy
var mIntValueA = 5;
var mIntValueB = 2;
var mIntValueC = 12;
var mIntValueD = 4;
var mIntValueE = 3;

var mIntValue1 = mIntValueA + mIntValueC; //Addition
console.log(Addition result: ${mIntValue1}); var mIntValue2 = mIntValueC - mIntValueD; //Subtraction console.log(Subtraction result:${mIntValue2});
var mIntValue3 = mIntValueA * mIntValueE; //Multiplication
console.log(Multiplication result:  ${mIntValue3}); var mIntValue4 = mIntValueC / mIntValueB; //Division console.log(Division result:${mIntValue4});
var mIntValue5 = mIntValueD % mIntValueE; //Modulus
console.log(Modulus result: ${mIntValue5}); # 2 Assignment Operators An assignment operator is responsible for giving a variable the result of a mathematical expression or the value of another variable, it assigns a value to its left operand based on the value of its right operand. The basic assignment operator is the equal (=), that is, x = y assigns the value of y to x. If the two operands in the assignment expression are different data types, the value of the right expression will automatically be converted to the left identifier type, so the assignment expression will be the same data type. The other assignment operators are usually abbreviations for standard operations. Basic arithmetic operators include: • ( = ) Assign • ( += ) Add and assign • ( -= ) Subtract and assign • ( *= ) Multiply and assign • ( /= ) Divide and assign quotient • ( %= ) Divide and assign modulus Copy <xsql-script> <body> <set name='m_value_a'>5</set> <set name='m_value_b'>2</set> <set name='m_value_c'>12</set> <set name='m_value_d'>4</set> <set name='m_value_e'>3</set> <set name='m_value_f'>'Assignment, '</set> <set name='m_value_g'>'Operators'</set> <set name='m_value1'><m_value_c /></set> <!-- Assignment --> <println>Assignment result: [<m_value1/>]</println> <set name='m_value2'> <!-- Addition Number + Number --> <add> <m_value_a /><m_value_c /> </add> </set> <println>Addition result: [<m_value2/>]</println> <set name='m_value3'> <!-- Concatenation String + String --> <add> <m_value_f /><m_value_g /> </add> </set> <println>Concatenation result: [<m_value3/>]</println> <set name='m_value4'> <!-- Subtraction --> <sub> <m_value_c /><m_value_d /> </sub> </set> <println>Subtraction result: [<m_value4/>]</println> <set name='m_value5'> <!-- Multiplication --> <mul> <m_value_a /><m_value_e /> </mul> </set> <println>Multiplication result: [<m_value5/>]</println> <set name='m_value6'> <!-- Division --> <div> <m_value_c /><m_value_b /> </div> </set> <println>Division result: [<m_value6/>]</println> <set name='m_value7'> <!-- Modulus --> <mod> <m_value_a /><m_value_b /> </mod> </set> <println>Modulus result: [<m_value7/>]</println> </body> </xsql-script> Copy var mIntValueA = 5; var mIntValueB = 2; var mIntValueC = 12; var mIntValueD = 4; var mIntValueE = 3; var mIntValueF = 6; var mIntValueG = 10; var mIntValueH = 8; var mIntValueX; var mIntValueY = 'Assignment, '; var mIntValueZ = 'Operators'; console.log(Assigment${mIntValueX = mIntValueC});  //Assignment
console.log(Addition ${mIntValueA += mIntValueC}); //Addition: Number + Number console.log(Concatenation${mIntValueY += mIntValueZ}); //Concatenation: String + String
console.log(Subtraction ${mIntValueC -= mIntValueD}); //Subtraction console.log(Multiplication${mIntValueF *= mIntValueE}); //Multiplication
mIntValueH /= mIntValueB
console.log(Division ${mIntValueH}); //Division console.log(Modulus${mIntValueG %= mIntValueE}); //Modulus

# 3 Comparison Operators

The comparison operators compare two or more values, either numbers or texts, to obtain a result, which would be a logical value.In the case that the result of the comparison is correct, the logical value true is obtained as a result; and in the opposite case, the logical value false is obtained as a result. Mathematically speaking, the result true is equal to 1 and false is equal to 0.

It must be taken into account, like in the Arithmetic Operators, that when the formula is executed there is a predetermined order in which the calculations have to go, which is the same of any mathematical operation.

Basic comparison operators include:

• ( == ) Equal to
• ( != ) Not equal
• ( > ) Greater than
• ( < ) Less than
• ( >= ) Greater than or equal to
• ( <= ) Less than or equal to
Copy
<xsql-script>
<body>
<set name='m_value_a'>50</set>
<set name='m_value_b'>75</set>
<set name='m_value_c'>100</set>
<set name='m_value_d'>50</set>

<println>Result equal: <eq><m_value_a /><m_value_d /></eq></println> <!-- Equal to-->
<println>Result not equal: <ne><m_value_c /><m_value_b /></ne></println> <!-- Not equal-->
<println>Result less: <lt><m_value_a /><m_value_c /></lt></println> <!-- Less than-->
<println>Result greater: <gt><m_value_b /><m_value_c /></gt></println> <!-- Greater than-->
<println>Result less or equal: <le><m_value_c /><m_value_a /></le></println> <!-- Less than or equal to-->
<println>Result greater or equal: <ge><m_value_c /><m_value_d /></ge></println> <!-- Greater than or equal to-->

</body>
</xsql-script>
Copy
var mIntValueA = 50;
var mIntValueB = 75;
var mIntValueC = 100;
var mIntValueD = 50;

console.log(Equal to: ${mIntValueA == mIntValueD}); //Equal to console.log(Not equal:${mIntValueC != mIntValueB});  //Not equal
console.log(Less than: ${mIntValueA < mIntValueC}); //Less than console.log(Greater than:${mIntValueB > mIntValueC});   //Greater than
console.log(Less than or equal to: ${mIntValueC <= mIntValueA}); //Less than or equal to console.log(Greater than or equal to:${mIntValueC >= mIntValueD});  //Greater than or equal to

# 4 Logical Operators

Logical operators are used to solve logical relationships. Like comparison operators, logical operators always return true or false.

To perform logical operations, all numerical and complex values other than 0 are validated as true, while the values 0 will always be false. These operators can be combined to express complex relationships. The logical and comparison operators can be related too, since the latter result in a Boolean data.

#### Boolean data

A boolean data type is any data of true or false value, yes or no value, or on or off (1 or 0) value.

Logical operators include:

• ( && ) Logical and
• ( || ) Logical or
• ( ! ) Logical not
Copy
<xsql-script>
<body>
<set name='m_value1'><true /></set>
<set name='m_value2'><false /></set>

<println>Result1 and: <expr><m_value1 /><and /><m_value1 /></expr></println>
<println>Result2 and: <expr><m_value1 /><and /><m_value2 /></expr></println>

<println>Result1 or: <expr><m_value1 /><or /><m_value2 /></expr></println>
<println>Result2 or: <expr><m_value2 /><or /><m_value2 /></expr></println>

<println>Result not: <expr><not><m_value1 /></not></expr></println>

</body>
</xsql-script>
Copy
var mBoolValueA = true;
var mBoolValueB = false;

console.log(Result1 and: ${mBoolValueA && mBoolValueA}); console.log(Result2 and:${mBoolValueA && mBoolValueB});

console.log(Result1 or: ${mBoolValueA || mBoolValueB}); console.log(Result2 or:${mBoolValueB || mBoolValueB});

console.log(Result not: ${!mBoolValueA}); # 5 Booleans data The boolean data type is one that can represent values of binary logic, that is, values that represent false or true. A boolean data type is any type of data with a true or false value, with a yes or no value, or with an on or off value (1 or 0). By default, the boolean data type is set to false. To obtain a Boolean data you can use basic comparison operators: • ( == ) Equal to • ( > ) Greater than • ( < ) Less than Copy <xsql-script> <body> <set name='m_value1'>25</set> <set name='m_value2'>15</set> <println>Result equal: <expr><eq><m_value1 /><m_value1 /></eq></expr></println> <println>Result greater: <expr><gt><m_value1 /><m_value2 /></gt></expr></println> <println>Result1 less: <expr><lt><m_value1 /><m_value2 /></lt></expr></println> </body> </xsql-script> Copy var mIntValueA = 25; var mIntValueB = 15; console.log(Result equal:${mIntValueA == mIntValueA});

console.log(Result greater:  ${mIntValueA > mIntValueB}); console.log(Result1 less:${mIntValueA < mIntValueB});

## 5.1 Booleans data true/false

At this point it is specified when a boolean data returns true or false depending on the language used.

Copy
<xsql-script>
<body>
<set name='m_value1' type='boolean'>25</set>    <!-- When a value is an integer, return true -->
<set name='m_value2' type='boolean'>2.5</set>   <!-- When a value is decimal, return true -->
<set name='m_value3' type='boolean'>0</set>     <!-- When a value is zero, return false -->
<set name='m_value4' type='boolean'>null</set>  <!-- When a value is null, return false -->

<println>Return <expr><m_value1 /></expr></println>
<println>Return <expr><m_value2 /></expr></println>
<println>Return <expr><m_value3 /></expr></println>
<println>Return <expr><m_value4 /></expr></println>

</body>
</xsql-script>
Copy
var mBoolValueA = Boolean(25);         // When a value is integer, return true
var mBoolValueB = Boolean(-25);        // when a value is a negative integer, return true
var mBoolValueC = Boolean(2.5);        // When a value is decimal, return true
var mBoolValueD = Boolean("Deister");  // When a value is string, return true

var mBoolValueE = Boolean(0);          // When a value is zero o minus zero, return false
var mBoolValueF = Boolean(undefined);  // When a value is undefined, return false
var mBoolValueG = Boolean(null);       // When a value is null, return false
var mBoolValueH = Boolean(false);      // When a value is false, return false
var mBoolValueI = Boolean('');         // When a value is empty string, return false

console.log("When a value is integer, return", mBoolValueA);
console.log("when a value is a negative integer, return ", mBoolValueB);
console.log("When a value is decimal, return ", mBoolValueC);
console.log("When a value is string, return ", mBoolValueD);
console.log("When a value is zero o minus zero, return ", mBoolValueE);
console.log("When a value is undefined, return ", mBoolValueF);
console.log("When a value is null, return ", mBoolValueG);
console.log("When a value is false, return ", mBoolValueH);
console.log("When a value is empty string, return ", mBoolValueI);