Numeric Operators

4D - Documentation   Français   English   German   Spanish   4D v11 SQL, Command Theme List   4D v11 SQL, Command Alphabetical List   4D v11 SQL, Constant Theme List   Back   Previous   Next

version 6.0


An expression that uses a numeric operator returns a number. The following table shows the numeric operators:

OperationSyntaxReturnsExpressionValue
AdditionNumber + NumberNumber2 + 35
SubtractionNumber – NumberNumber3 – 21
MultiplicationNumber * NumberNumber5 * 210
DivisionNumber /NumberNumber5 / 22.5
Longint divisionNumber \ NumberNumber5 \ 22
ModuloNumber % NumberNumber5 % 21
ExponentiationNumber ^ NumberNumber2 ^ 38

Modulo Operator

The modulo operator % divides the first number by the second number and returns a whole number remainder. Here are some examples:

10 % 2 returns 0 because 10 is evenly divided by 2.

10 % 3 returns 1 because the remainder is 1.

10.5 % 2 returns 0 because the remainder is not a whole number.

WARNING:

The modulo operator % returns significant values with numbers that are in the Long Integer range (from minus 2^31 to 2^31 minus one). To calculate the modulo with numbers outside of this range, use the Mod command.

The longint division operator \ returns significant values with integer numbers only.

See Also

Bitwise Operators, Comparison Operators, Date Operators, Logical Operators, Operators, Picture Operators, String Operators, Time Operators.


4D - Documentation   Français   English   German   Spanish   4D v11 SQL, Command Theme List   4D v11 SQL, Command Alphabetical List   4D v11 SQL, Constant Theme List   Back   Previous   Next