Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:iot-open:introductiontoembeddedprogramming2:cppfundamentals:operators [2023/11/21 19:34] ktokarzen:iot-open:introductiontoembeddedprogramming2:cppfundamentals:operators [2023/11/23 10:20] (current) pczekalski
Line 1: Line 1:
 ====== Operators, Specifiers and Pointers ====== ====== Operators, Specifiers and Pointers ======
 +{{:en:iot-open:czapka_b.png?50| General audience classification icon }}{{:en:iot-open:czapka_e.png?50| General audience classification icon }}\\
 Operators represent mathematical, relational, bitwise, conditional, or logical data manipulations. There are many operators in the C/C++ language. In this chapter, the most important are presented. Logical operators will be shown in the next chapter as they are used together with conditional statements. Operators represent mathematical, relational, bitwise, conditional, or logical data manipulations. There are many operators in the C/C++ language. In this chapter, the most important are presented. Logical operators will be shown in the next chapter as they are used together with conditional statements.
  
-==== Assignment Operator ====+===== Assignment Operator =====
  
   * **Assignment operator ( = )** – the operator that assigns the value on the right to the variable on the assignment operator's left. The left side should represent the variable (must be able to be modified), and the right side can be the number (constant), variable, or expression. In the case of an expression, its value is first calculated, and then the result is assigned to the variable on the left. The work of an assignment operator can be seen in any of the following operation examples.   * **Assignment operator ( = )** – the operator that assigns the value on the right to the variable on the assignment operator's left. The left side should represent the variable (must be able to be modified), and the right side can be the number (constant), variable, or expression. In the case of an expression, its value is first calculated, and then the result is assigned to the variable on the left. The work of an assignment operator can be seen in any of the following operation examples.
  
-=== 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:
 </code> </code>
  
-=== 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 "1" at the chosen bit position, the resulting bit will also be "1". Bitwise and ( & ) means that if at least one bit is "0", the resulting bit is "0". Bitwise operators shouldn't be confused with Logic Operators ( || ), ( && ), which operate on a single boolean logic value. 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 "1" at the chosen bit position, the resulting bit will also be "1". Bitwise and ( & ) means that if at least one bit is "0", the resulting bit is "0". Bitwise operators shouldn't be confused with Logic Operators ( || ), ( && ), which operate on a single boolean logic value.
Line 71: Line 71:
 </code> </code>
  
-=== 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:
 </code> </code>
  
-=== & 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.
en/iot-open/introductiontoembeddedprogramming2/cppfundamentals/operators.1700595273.txt.gz · Last modified: 2023/11/21 19:34 by ktokarz
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0