Mathematical Operators are widely used in programming in case of problem solving; calculations will always be used for performing numerous tasks. The main mathematical operators are:

 

+ (Sum)

– (subtraction)

* (multiplication)

/ (division)

 

It is very important to know that, as in mathematics, operations in programming logic follow an order. There is an order of precedence between these operators:

 

  • First: () – parentheses;
  • Second, * (multiplication) and / (division), the one that first appear;
  • Third: + (sum) or – (minus), the one that first appear.

 

Relational operators are used to compare two values that can be variable or constant, of the same type. Examples of relational operators:

 

  • = (less than)
  • > (greater than)
  • <(less than)
  • <> (different from)
  • > = (greater than or equal to)
  • <= (less than or equal to)

 

These operators are often used and the result of these comparisons implies a logical value (true or false):

 

10> = 5 (true)

11 <> 11 (false)

0.5 <(-1) (false)

The A = (true)

 

 

Finally, the logical operators are combined to the expressions. Thus we got a true or false value. The main logical operators are:

 

  • AND – conjunction
  • Or – disjunction
  • No – denial

 

The “E” and “or” are binary operators. This means that they serve to combine two expressions. The “No” is a unary operator. This means that it serves to change the value of an expression. To better understand how they are used, see the following expressions:

 

  1. Has electricity;
  2. The computer is plugged in.

 

 

 

 

 

So that the computer turns on, you have to obey the two previous expressions. Imagine the following relationship:

 

(Expression 1) and (Expression 2)

 

If one of these expressions is not true, the condition is false (The computer does not start). The computer turns on only if both are true. The possibilities table of a condition is called Truth Table:

 

Expression 1 and Expression 2

FALSE FALSE FALSE

FALSE FALSE TRUE

TRUE FALSE FALSE

TRUE TRUE TRUE

 

The logical operators can be combined in countless ways. As mathematical, logical operators follow an order of precedence (priority):

 

  1. () – Parentheses.
  2. No – Denial.
  3. E – Conjunction.
  4. Or – disjunction

You might also like…

Scriptcase & Web Services

This time I will explain how to work with web services inside the Scriptcase, directly with PHP and...

More updates in 9.4 version

Recently version 9.4 was released bringing a new design concept to the generated applications of Sc...

Taking a look at version 9.4

Scriptcase released its version 9.4, and this one brings many interesting news, specially regarding...

Comment this post

Get new posts, resources, offers and more each week.

We will use the information you provide to update you about our Newsletter and Special Offers. You can unsubscribe any time you want by clinck in a link in the footer of any email you receive from us, or by contacting us at sales@scriptcase.net. Learn more about our Privacy Police.