02-14-2023, 07:21 PM
(This post was last modified: 02-14-2023, 07:34 PM by Kernelpanic.)
As already mentioned, the order in which the individual operators are considered is important.
Different operators at the same level are so executed: the leftmost operation first, the rightmost operation last.
If one want to be absolutely sure that a calculation is carried out in a certain order, then one just put brackets.
(a = 4.000 - a2 = 0.063 - a3 = 2.500)
Different operators at the same level are so executed: the leftmost operation first, the rightmost operation last.
If one want to be absolutely sure that a calculation is carried out in a certain order, then one just put brackets.
(a = 4.000 - a2 = 0.063 - a3 = 2.500)
Code: (Select All)
'Rangfolge von Operatoren - 14. Feb. 2023
'QuickBasic Befehlsverzeichnis 3.2
$Console:Only
Option _Explicit
Dim As Double a, a2, a3
a = 100 Mod 17 / 3
Print Using "###.###"; a
'There is one exception to the normal ranking:
'If an expression has adjacent exponentiation and negation operators,
'then the negation is performed first.
a2 = 4 ^ -2
Print Using "###.###"; a2
'The leftmost operation first, the rightmost operation last.
'According to their order of operations (Rangfolge)
a3 = 3 + 6 / 12 * 3 - 2
Print Using "###.###"; a3
End