Thursday, October 18, 2018 21:17

Assignment operators

January 6th, 2017

This is the simplest operator of them all. It’s expressed simply by the equal (=) sign. Assignment operators are used to assign (give) a value to a variable.

They can also be used in cascade. Lets have a look at simple and cascaded assignment:

One very important thing to always remember is NOT to confuse the assignment operator = with the comparison operator == (a very common programming mistake).… Read more

Comparison operators

January 6th, 2017

Another kind of operators we have enumerated are the comparison operators. As their name suggest, comparison operators are used to compare operands. There are 6 comparison operators:

All of the above operators return a Boolean value (true or false).… Read more

Bitwise operators

January 6th, 2017

Any programmer knows that computers can only process information represented by a series of binary numbers (1 and 0). This means that when we store the number 55 in memory of the computer, it actually stores a series of bits represented as 00110111.… Read more

Concatenator operator

January 6th, 2017

Though we already used the concatenator operator quite a few times, we did not explain it yet. The concatenator operator (+) is used to join values of type string together.

As a side note, it is not necessary for both operands to be of type string.… Read more

Logical operators

January 6th, 2017

Logical operators are quite simple, since they can only produce two outputs: true or false. The basic logical (Boolean) operators are AND (&&), OR (||),  XOR (also called “Exclusive OR”, ^) and NOT (or negation, !).

I will show you a sample of the four logical operations and the results that they produce:

Decrementing operator

January 6th, 2017

Decrementing operator is the complementary part of the incrementing operator. What applies to the incrementing operator, also applies for the decrementing one.

Obviously, the difference is in the syntax and behavior. Decrementing operator can be expressed in four ways, just like incrementing one:

The difference in behavior should be obvious and self-explanatory: instead of adding, we subtract.… Read more

Incrementing operator

January 5th, 2017

One of the most used operations in programming is incrementing a variable’s value. Incrementing operator is composed of two plus signs: ++ (and has two forms), or a variation of the following two operators: += and =+.

Lets consider the following example:

In the above example, we are assigning a variable the result of adding 1 to its own value.… Read more

Arithmetical operators

January 5th, 2017

Basically, arithmetical operators (+, -, *, /) are the same as the mathematical ones. However, there are a few things to point out.

The most important thing to watch out is the kind of result you are expecting. If you will use two integers to perform a division, do not expect to get a real number, do not expect to get rounding, or any fractional part.… Read more

Operator precedence

January 5th, 2017

If you still remember from math class (yeah, right! 😀 ), some operators have precedence over others, meaning that multiplication is more important than addition and will be calculated first. Operator precedence should always be remembered when dealing with more than two operands.… Read more

Operators

January 4th, 2017

No, we’re not talking about the landline phone operators 🙂 . As you can imagine, storing data in variables is pointless if we are not manipulating and/or using that data. Even in the most simple programs, you will use mathematical operations like subtraction, addition, multiplication, division.… Read more