This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
en:iot-open:introductiontoembeddedprogramming2:cppfundamentals:operators [2023/11/21 19:34] – ktokarz | en:iot-open:introductiontoembeddedprogramming2:cppfundamentals:operators [2023/11/23 10:20] (current) – pczekalski | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Operators, Specifiers and Pointers ====== | ====== Operators, Specifiers and Pointers ====== | ||
+ | {{: | ||
Operators represent mathematical, | Operators represent mathematical, | ||
- | ==== Assignment Operator ==== | + | ===== Assignment Operator |
* **Assignment operator ( = )** – the operator that assigns the value on the right to the variable on the assignment operator' | * **Assignment operator ( = )** – the operator that assigns the value on the right to the variable on the assignment operator' | ||
- | === Arithmetic Operators === | + | ==== Arithmetic Operators |
Arithmetic operations are used to do mathematical calculations with numbers or numerical variables. The arithmetic operators are the following. | Arithmetic operations are used to do mathematical calculations with numbers or numerical variables. The arithmetic operators are the following. | ||
Line 37: | Line 37: | ||
</ | </ | ||
- | === Bitwise Operators === | + | ==== Bitwise Operators |
Bitwise operators perform operations on bits in the variable. Among them, there exist bitwise logic operations. It means the same logic function is applied to every pair of bits in two arguments. Bitwise or ( | ) means that if at least one bit is " | Bitwise operators perform operations on bits in the variable. Among them, there exist bitwise logic operations. It means the same logic function is applied to every pair of bits in two arguments. Bitwise or ( | ) means that if at least one bit is " | ||
Line 71: | Line 71: | ||
</ | </ | ||
- | === Compound Operators === | + | ==== Compound Operators |
Compound operators in C/C++ are a short way of writing down the arithmetic operations with variables. All of these operations are done on integer variables. These operands are often used in the loops when it is necessary to manipulate the same variable in each cycle iteration. The compound operators are the following. | Compound operators in C/C++ are a short way of writing down the arithmetic operations with variables. All of these operations are done on integer variables. These operands are often used in the loops when it is necessary to manipulate the same variable in each cycle iteration. The compound operators are the following. | ||
Line 122: | Line 122: | ||
</ | </ | ||
- | === & and * Operators: Pointers and References === | + | ==== & and * Operators: Pointers and References |
Simple and complex types can be referred to with pointer variables. A pointer is a variable that holds the address of the variable. The length of the pointer is equivalent to the length of the memory address (usually 16, 32 or 64 bits). A pointer does not contain a value but instead points to the variable (a memory) where the value is stored. A pointer variable must be initialised and dereferenced with Address-Of and Dereferencing operators.\\ | Simple and complex types can be referred to with pointer variables. A pointer is a variable that holds the address of the variable. The length of the pointer is equivalent to the length of the memory address (usually 16, 32 or 64 bits). A pointer does not contain a value but instead points to the variable (a memory) where the value is stored. A pointer variable must be initialised and dereferenced with Address-Of and Dereferencing operators.\\ | ||
The following example presents a simple type declaration and the use of a pointer variable. | The following example presents a simple type declaration and the use of a pointer variable. |