ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage syntax / Operators
  • Use
  • Rules
  • Calculation rules
  • Notes
  • Displaying the result
  • Equivalence
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Arithmetic operators
Use
The arithmetic operators are:
  • "+": Addition (Numerical value or string).
  • "-": Subtraction (Numerical value).
  • "*": Multiplication.
  • "/": Division.
  • "++": Increment (numerical value).
  • "--" Decrement (Numerical value).
  • "+=": Adds a value to the variable or field (Numerical or Text).
  • "-=": Subtracts a value from the variable or field (Numerical).
  • Modulo: Returns the remainder of a division.
  • "%": Returns the remainder of an integer division (Modulo equivalent).
  • "^" Power (equivalent to Power).
Rules

Calculation rules

The different calculations are performed without loss of precision and without being truncated. The flow checks are performed when the result is assigned to a variable.
Notes

Displaying the result

The result of the calculation can be directly displayed using the following operators:
  • "++": Increment
  • "--" Decrement
When the ++ (--) operator is used as an expression (for example: Info(x++)), its behavior is determined by the position of the operator, relative to the incremented variable:
  • ++x (--x) => increments (decrements) x then returns x.
  • x++ (x--) => returns the value of x then increments (decrements) x.
For example:
let x is int = 5
Trace(x++) 	// Affiche 5. x vaut 6 
Trace(++x) 	// Affiche 7. x vaut 7
Trace(--x) 	// Affiche 6. x vaut 6
Trace(x--) 	// Affiche 6. x vaut 5
Trace(x)	// Affiche 5
The result of the calculation cannot be directly displayed by the following operators:
  • "+=": Add a value to the variable or field (Numerical or Text)
  • "-=": Subtracts a value from the variable or field (Numerical)
Therefore, this example generates an error during the compilation:
num is int = 10
Trace(num+=1)
To display the result, perform the following modifications:
num is int = 10
num += 1
Trace(num)

Equivalence

  • j ++ is equivalent to j = j + 1
  • j -- is equivalent to j = j - 1
  • j += 3 is equivalent to j = j + 3
  • j -= 3 is equivalent to j = j - 3
We recommend using the syntaxes: "j ++", "j --", "j +=" and "j -=", which are faster than the usual syntaxes.
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 09/20/2024

Send a report | Local help